@univerjs-pro/exchange-client 0.2.6
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 +24 -0
- package/lib/cjs/index.js +2 -0
- package/lib/es/index.js +2 -0
- package/lib/index.css +1 -0
- package/lib/locale/en-US.json +20 -0
- package/lib/locale/ru-RU.json +20 -0
- package/lib/locale/vi-VN.json +20 -0
- package/lib/locale/zh-CN.json +20 -0
- package/lib/locale/zh-TW.json +20 -0
- package/lib/types/controllers/exchange.controller.d.ts +9 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/locale/vi-VN.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +21 -0
- package/lib/types/locale/zh-TW.d.ts +4 -0
- package/lib/types/plugin.d.ts +11 -0
- package/lib/types/services/exchange.service.d.ts +88 -0
- package/lib/types/services/operate.service.d.ts +97 -0
- package/lib/types/services/request.service.d.ts +105 -0
- package/lib/types/services/upload-notification.service.d.ts +53 -0
- package/lib/types/services/upload-progress.service.d.ts +5 -0
- package/lib/types/services/utils/snapshot.d.ts +53 -0
- package/lib/types/services/utils/tool.d.ts +20 -0
- package/lib/types/views/UploadNotificationContainer.d.ts +3 -0
- package/lib/types/views/link-list/LinkList.d.ts +7 -0
- package/lib/types/views/upload-again/UploadAgain.d.ts +3 -0
- package/lib/types/views/upload-button/UploadButton.d.ts +8 -0
- package/lib/types/views/upload-error/UploadError.d.ts +3 -0
- package/lib/types/views/upload-notification/UploadNotification.d.ts +3 -0
- package/lib/types/views/upload-success/UploadSuccess.d.ts +6 -0
- package/lib/types/views/uploading/Uploading.d.ts +3 -0
- package/lib/types/views/uploading/upload-cancel/UploadCancel.d.ts +3 -0
- package/lib/types/views/uploading/upload-progress/UploadProgress.d.ts +6 -0
- package/lib/umd/index.js +2 -0
- package/package.json +91 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
export { IExchangeService, ExchangeService } from './services/exchange.service';
|
2
|
+
export { getUploadFile, downloadFile, getUniverTypeByFile } from './services/utils/tool';
|
3
|
+
export { IUploadNotificationService, UploadNotificationService, UploadNotificationState } from './services/upload-notification.service';
|
4
|
+
export { IUploadProgressService, UploadProgressService } from './services/upload-progress.service';
|
5
|
+
export { UploadNotificationContainer } from './views/UploadNotificationContainer';
|
6
|
+
export { RequestService, IRequestService } from './services/request.service';
|
7
|
+
export { EXCHANGE_UPLOAD_FILE_SERVER_URL_KEY, EXCHANGE_IMPORT_SERVER_URL_KEY, EXCHANGE_EXPORT_SERVER_URL_KEY, EXCHANGE_GET_TASK_SERVER_URL_KEY, EXCHANGE_SIGN_URL_SERVER_URL_KEY } from './services/request.service';
|
8
|
+
export { IExchangeOperateService } from './services/operate.service';
|
9
|
+
export { UniverExchangeClientPlugin } from './plugin';
|
@@ -0,0 +1,21 @@
|
|
1
|
+
declare const locales: {
|
2
|
+
exchange: {
|
3
|
+
file: string;
|
4
|
+
upload: string;
|
5
|
+
download: string;
|
6
|
+
uploading: string;
|
7
|
+
uploadSuccess: string;
|
8
|
+
uploadSuccessTip: string;
|
9
|
+
downloading: string;
|
10
|
+
downloadSuccess: string;
|
11
|
+
unknownMistake: string;
|
12
|
+
networkError: string;
|
13
|
+
tooLarge: string;
|
14
|
+
internalError: string;
|
15
|
+
interrupt: string;
|
16
|
+
wait: string;
|
17
|
+
cancel: string;
|
18
|
+
uploadAgain: string;
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export default locales;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Injector, LocaleService, Plugin } from '@univerjs/core';
|
2
|
+
|
3
|
+
export declare class UniverExchangeClientPlugin extends Plugin {
|
4
|
+
private readonly _;
|
5
|
+
readonly _injector: Injector;
|
6
|
+
private readonly _localeService;
|
7
|
+
static pluginName: string;
|
8
|
+
constructor(_: undefined, _injector: Injector, _localeService: LocaleService);
|
9
|
+
initialize(): void;
|
10
|
+
onReady(): void;
|
11
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { IDisposable, IDocumentData, IWorkbookData, Disposable } from '@univerjs/core';
|
2
|
+
import { IError, UniverType } from '@univerjs/protocol';
|
3
|
+
import { Observable } from 'rxjs';
|
4
|
+
import { RequestService } from './request.service';
|
5
|
+
|
6
|
+
export declare enum RequestState {
|
7
|
+
UPLOAD = 0,
|
8
|
+
IMPORT = 1,
|
9
|
+
EXPORT = 2,
|
10
|
+
GET_TASK = 3,
|
11
|
+
SIGN_URL = 4,
|
12
|
+
GET_JSON = 5,
|
13
|
+
GET_FILE = 6,
|
14
|
+
BINDING = 7
|
15
|
+
}
|
16
|
+
export interface IRequestState {
|
17
|
+
error: IError | undefined;
|
18
|
+
state: RequestState;
|
19
|
+
}
|
20
|
+
export interface IExchangeService {
|
21
|
+
requestState$: Observable<IRequestState>;
|
22
|
+
/**
|
23
|
+
* Import XLSX file to workbook data
|
24
|
+
* @param file
|
25
|
+
*/
|
26
|
+
importXLSXToSnapshot(file: File | string): Promise<IWorkbookData | undefined>;
|
27
|
+
/**
|
28
|
+
* Export XLSX file by unit id
|
29
|
+
* @param unitId
|
30
|
+
*/
|
31
|
+
exportXLSXByUnitId(unitId: string): Promise<File | undefined>;
|
32
|
+
/**
|
33
|
+
* Export XLSX file by workbook data
|
34
|
+
* @param data
|
35
|
+
* @returns
|
36
|
+
*/
|
37
|
+
exportXLSXBySnapshot(snapshot: IWorkbookData): Promise<File | undefined>;
|
38
|
+
/**
|
39
|
+
* Import DOCX file to document data
|
40
|
+
* @param file
|
41
|
+
*/
|
42
|
+
importDOCXToSnapshot(file: File | string): Promise<IDocumentData | undefined>;
|
43
|
+
/**
|
44
|
+
* Export DOCX file by unit id
|
45
|
+
* @param unitId
|
46
|
+
*/
|
47
|
+
exportDOCXByUnitId(unitId: string): Promise<File | undefined>;
|
48
|
+
/**
|
49
|
+
* Export DOCX file by document data
|
50
|
+
* @param data
|
51
|
+
* @returns
|
52
|
+
*/
|
53
|
+
exportDOCXBySnapshot(snapshot: IDocumentData): Promise<File | undefined>;
|
54
|
+
/**
|
55
|
+
* Import file to unit id
|
56
|
+
* @param file
|
57
|
+
* @param univerType
|
58
|
+
*/
|
59
|
+
importFileToUnitId(file: File | string, univerType: UniverType): Promise<string | undefined>;
|
60
|
+
}
|
61
|
+
export declare const IExchangeService: import('@univerjs/core').IdentifierDecorator<IExchangeService>;
|
62
|
+
export declare class ExchangeService extends Disposable implements IExchangeService, IDisposable {
|
63
|
+
private readonly _requestService;
|
64
|
+
private readonly _requestState$;
|
65
|
+
readonly requestState$: Observable<IRequestState>;
|
66
|
+
constructor(_requestService: RequestService);
|
67
|
+
dispose(): void;
|
68
|
+
importDOCXToSnapshot(file: File | string): Promise<IDocumentData | undefined>;
|
69
|
+
exportDOCXByUnitId(unitId: string): Promise<File | undefined>;
|
70
|
+
exportDOCXBySnapshot(snapshot: IDocumentData): Promise<File | undefined>;
|
71
|
+
importXLSXToSnapshot(file: File | string): Promise<IWorkbookData | undefined>;
|
72
|
+
exportXLSXByUnitId(unitId: string): Promise<File | undefined>;
|
73
|
+
exportXLSXBySnapshot(data: IWorkbookData): Promise<File | undefined>;
|
74
|
+
importFileToUnitId(file: File | string, univerType: UniverType): Promise<string | undefined>;
|
75
|
+
private _importToSnapshot;
|
76
|
+
/**
|
77
|
+
* Export file by snapshot
|
78
|
+
* @param snapshot
|
79
|
+
* @param univerType
|
80
|
+
* @returns
|
81
|
+
*/
|
82
|
+
private _exportBySnapshot;
|
83
|
+
private _export;
|
84
|
+
private _upload;
|
85
|
+
private _import;
|
86
|
+
private _signUrl;
|
87
|
+
private _binding;
|
88
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { IDisposable, Disposable, ILogService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';
|
2
|
+
import { IProgressService, IMessageService } from '@univerjs/ui';
|
3
|
+
import { UniverType } from '@univerjs/protocol';
|
4
|
+
import { ExchangeService } from './exchange.service';
|
5
|
+
import { UploadNotificationService } from './upload-notification.service';
|
6
|
+
|
7
|
+
export interface IExchangeOperateService {
|
8
|
+
interrupt(): void;
|
9
|
+
/**
|
10
|
+
* Upload file to server, get unitId and open unit
|
11
|
+
* @param file
|
12
|
+
*/
|
13
|
+
importXLSXToUnitId(): Promise<string | undefined>;
|
14
|
+
/**
|
15
|
+
* Upload xlsx file to server, get snapshot and refresh current sheet
|
16
|
+
* @param file
|
17
|
+
*/
|
18
|
+
importXLSXToSnapshot(): Promise<void>;
|
19
|
+
/**
|
20
|
+
* Export xlsx file by unitId
|
21
|
+
* @returns
|
22
|
+
*/
|
23
|
+
exportXLSXByUnitId(unitId?: string, unitName?: string, unitType?: UniverInstanceType): Promise<void>;
|
24
|
+
/**
|
25
|
+
* Export xlsx file by snapshot
|
26
|
+
* @returns
|
27
|
+
*/
|
28
|
+
exportXLSXBySnapshot(): Promise<void>;
|
29
|
+
/**
|
30
|
+
* Upload file to server, get unitId and open unit
|
31
|
+
* @param file
|
32
|
+
*/
|
33
|
+
importDOCXToUnitId(): Promise<string | undefined>;
|
34
|
+
/**
|
35
|
+
* Upload docx file to server, get snapshot and refresh current doc
|
36
|
+
* @param file
|
37
|
+
*/
|
38
|
+
importDOCXToSnapshot(): Promise<void>;
|
39
|
+
/**
|
40
|
+
* Export docx file by unitId
|
41
|
+
* @returns
|
42
|
+
*/
|
43
|
+
exportDOCXByUnitId(unitId?: string, unitName?: string, unitType?: UniverInstanceType): Promise<void>;
|
44
|
+
/**
|
45
|
+
* Export docx file by snapshot
|
46
|
+
* @returns
|
47
|
+
*/
|
48
|
+
exportDOCXBySnapshot(): Promise<void>;
|
49
|
+
/**
|
50
|
+
* Upload file, supports multiple types
|
51
|
+
* @param file
|
52
|
+
*/
|
53
|
+
uploadFileToUnitId(types: UniverType[]): Promise<string | undefined>;
|
54
|
+
/**
|
55
|
+
* Customize the imported Unit URL format according to the needs of your own scene
|
56
|
+
* @param getLink
|
57
|
+
*/
|
58
|
+
registerLink(getLink: (unitId: string, univerType: UniverInstanceType) => string): void;
|
59
|
+
}
|
60
|
+
export declare const IExchangeOperateService: import('@univerjs/core').IdentifierDecorator<IExchangeOperateService>;
|
61
|
+
export declare class ExchangeOperateService extends Disposable implements IExchangeOperateService, IDisposable {
|
62
|
+
private _univerInstanceService;
|
63
|
+
private readonly _messageService;
|
64
|
+
private readonly _localeService;
|
65
|
+
private readonly _exchangeService;
|
66
|
+
private readonly _uploadNotificationService;
|
67
|
+
private readonly _uploadProgressService;
|
68
|
+
protected readonly _logService: ILogService;
|
69
|
+
private _interrupted;
|
70
|
+
constructor(_univerInstanceService: IUniverInstanceService, _messageService: IMessageService, _localeService: LocaleService, _exchangeService: ExchangeService, _uploadNotificationService: UploadNotificationService, _uploadProgressService: IProgressService, _logService: ILogService);
|
71
|
+
interrupt(): void;
|
72
|
+
uploadFileToUnitId(types: UniverType[]): Promise<string | undefined>;
|
73
|
+
importDOCXToUnitId(): Promise<string | undefined>;
|
74
|
+
importDOCXToSnapshot(): Promise<void>;
|
75
|
+
exportDOCXByUnitId(unitId?: string, unitName?: string, unitType?: UniverInstanceType): Promise<void>;
|
76
|
+
exportDOCXBySnapshot(): Promise<void>;
|
77
|
+
importXLSXToUnitId(): Promise<string | undefined>;
|
78
|
+
importXLSXToSnapshot(): Promise<void>;
|
79
|
+
exportXLSXByUnitId(unitId?: string, unitName?: string): Promise<void>;
|
80
|
+
exportXLSXBySnapshot(): Promise<void>;
|
81
|
+
registerLink(getLink: (unitId: string, univerType: UniverInstanceType) => string): void;
|
82
|
+
private _importFileToUnitId;
|
83
|
+
private _getUnitID;
|
84
|
+
private _getUnitName;
|
85
|
+
private _getUnitJson;
|
86
|
+
/**
|
87
|
+
* Get unit link /?unit={unitId}&type=2
|
88
|
+
* @param unitId
|
89
|
+
* @param type
|
90
|
+
* @returns
|
91
|
+
*/
|
92
|
+
private _getLinkByUnitId;
|
93
|
+
private _refresh;
|
94
|
+
private _showNetworkError;
|
95
|
+
private _showDownloadMessage;
|
96
|
+
private _showUploadMessage;
|
97
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { IConfigService, IDisposable } from '@univerjs/core';
|
2
|
+
import { HTTPService } from '@univerjs/network';
|
3
|
+
import { IError, UniverType } from '@univerjs/protocol';
|
4
|
+
import { ISheetBlockJson, ISnapshotJson } from './utils/snapshot';
|
5
|
+
|
6
|
+
export declare const EXCHANGE_UPLOAD_FILE_SERVER_URL_KEY = "EXCHANGE_UPLOAD_FILE_SERVER_URL_KEY";
|
7
|
+
export declare const EXCHANGE_IMPORT_SERVER_URL_KEY = "EXCHANGE_IMPORT_SERVER_URL_KEY";
|
8
|
+
export declare const EXCHANGE_EXPORT_SERVER_URL_KEY = "EXCHANGE_EXPORT_SERVER_URL_KEY";
|
9
|
+
export declare const EXCHANGE_GET_TASK_SERVER_URL_KEY = "EXCHANGE_GET_TASK_SERVER_URL_KEY";
|
10
|
+
export declare const EXCHANGE_SIGN_URL_SERVER_URL_KEY = "EXCHANGE_SIGN_URL_SERVER_URL_KEY";
|
11
|
+
export declare const EXCHANGE_BINDING_SERVER_URL_KEY = "EXCHANGE_BINDING_SERVER_URL_KEY";
|
12
|
+
export interface IFileUploadResponse {
|
13
|
+
FileId: string;
|
14
|
+
error: IError;
|
15
|
+
}
|
16
|
+
export declare enum ImportOutputType {
|
17
|
+
UNDEFINED = 0,
|
18
|
+
/** UNIT - Import to univer unit, unit is store in the database */
|
19
|
+
UNIT = 1,
|
20
|
+
/** JSON - Import and convert to a json file which represents a univer unit, not store in the database */
|
21
|
+
JSON = 2,
|
22
|
+
UNRECOGNIZED = -1
|
23
|
+
}
|
24
|
+
export interface IImportRequest {
|
25
|
+
fileID: string;
|
26
|
+
type: UniverType;
|
27
|
+
outputType: ImportOutputType;
|
28
|
+
/** not supported yet */
|
29
|
+
fileUrl: string;
|
30
|
+
}
|
31
|
+
export interface IImportResponse {
|
32
|
+
taskID: string;
|
33
|
+
error: IError;
|
34
|
+
}
|
35
|
+
export interface IExportRequest {
|
36
|
+
/** if unitID is specified, the input is the unit in the database */
|
37
|
+
unitID: string;
|
38
|
+
/** if jsonID is specified, the input is the json file which represents a univer unit */
|
39
|
+
jsonID: string;
|
40
|
+
type: UniverType;
|
41
|
+
}
|
42
|
+
export interface IExportResponse {
|
43
|
+
error: IError | undefined;
|
44
|
+
taskID: string;
|
45
|
+
}
|
46
|
+
export interface IGetTaskResponse {
|
47
|
+
error: IError | undefined;
|
48
|
+
taskID: string;
|
49
|
+
status: string;
|
50
|
+
import?: IImportTaskResult | undefined;
|
51
|
+
export?: IExportTaskResult | undefined;
|
52
|
+
}
|
53
|
+
export interface IImportTaskResult {
|
54
|
+
outputType: ImportOutputType;
|
55
|
+
unitID: string;
|
56
|
+
jsonID: string;
|
57
|
+
}
|
58
|
+
export interface IExportTaskResult {
|
59
|
+
fileID: string;
|
60
|
+
fileUrl: string;
|
61
|
+
}
|
62
|
+
export interface ISignUrlResponse {
|
63
|
+
error: IError | undefined;
|
64
|
+
url: string;
|
65
|
+
}
|
66
|
+
export interface IBindingResponse {
|
67
|
+
error: IError;
|
68
|
+
}
|
69
|
+
export interface ISnapshotJsonResponse {
|
70
|
+
snapshot: Partial<ISnapshotJson>;
|
71
|
+
sheetBlocks: ISheetBlockJson;
|
72
|
+
}
|
73
|
+
export interface IRequestService {
|
74
|
+
upload(file: File | string): Promise<IFileUploadResponse | undefined>;
|
75
|
+
import(importRequest: IImportRequest): Promise<IImportResponse | undefined>;
|
76
|
+
export(exportRequest: IExportRequest): Promise<IExportResponse | undefined>;
|
77
|
+
getTask(taskID: string): Promise<IGetTaskResponse | undefined>;
|
78
|
+
signUrl(fileID: string): Promise<ISignUrlResponse | undefined>;
|
79
|
+
}
|
80
|
+
export declare const IRequestService: import('@univerjs/core').IdentifierDecorator<IRequestService>;
|
81
|
+
/**
|
82
|
+
* TODO@Dushusir maybe move to ExchangeClientPlugin plugin for reuse
|
83
|
+
*/
|
84
|
+
export declare class RequestService implements IRequestService, IDisposable {
|
85
|
+
private readonly _configService;
|
86
|
+
private readonly _httpService;
|
87
|
+
constructor(_configService: IConfigService, _httpService: HTTPService);
|
88
|
+
dispose(): void;
|
89
|
+
/**
|
90
|
+
* upload file to server
|
91
|
+
* @param file
|
92
|
+
*/
|
93
|
+
upload(file: File | string, size?: number, flate?: boolean): Promise<IFileUploadResponse | undefined>;
|
94
|
+
import(importRequest: IImportRequest): Promise<IImportResponse | undefined>;
|
95
|
+
export(exportRequest: IExportRequest): Promise<IExportResponse | undefined>;
|
96
|
+
getTask(taskID: string): Promise<IGetTaskResponse | undefined>;
|
97
|
+
signUrl(fileID: string): Promise<ISignUrlResponse | undefined>;
|
98
|
+
binding(unitId: string, type: UniverType): Promise<IBindingResponse | undefined>;
|
99
|
+
private _getUploadFileURL;
|
100
|
+
private _getImportURL;
|
101
|
+
private _getExportURL;
|
102
|
+
private _getTaskURL;
|
103
|
+
private _getSignURL;
|
104
|
+
private _getBindingURL;
|
105
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Disposable, IDisposable } from '@univerjs/core';
|
2
|
+
import { Observable } from 'rxjs';
|
3
|
+
import { UniverType } from '@univerjs/protocol';
|
4
|
+
|
5
|
+
export declare enum UploadNotificationState {
|
6
|
+
UPLOADING = 0,
|
7
|
+
SUCCESS = 1,
|
8
|
+
ERROR = 2
|
9
|
+
}
|
10
|
+
export interface ILinkList {
|
11
|
+
link: string;
|
12
|
+
name: string;
|
13
|
+
type: UniverType;
|
14
|
+
}
|
15
|
+
export interface IUploadNotificationService {
|
16
|
+
visible$: Observable<boolean>;
|
17
|
+
state$: Observable<UploadNotificationState>;
|
18
|
+
list$: Observable<ILinkList[]>;
|
19
|
+
/**
|
20
|
+
* Show upload notification
|
21
|
+
*/
|
22
|
+
show(): void;
|
23
|
+
/**
|
24
|
+
* Hide upload notification
|
25
|
+
*/
|
26
|
+
hide(): void;
|
27
|
+
/**
|
28
|
+
* Update upload notification state
|
29
|
+
* @param state
|
30
|
+
*/
|
31
|
+
updateState(state: UploadNotificationState): void;
|
32
|
+
/**
|
33
|
+
* Push link to upload notification
|
34
|
+
* @param link
|
35
|
+
*/
|
36
|
+
pushLink(link: ILinkList): void;
|
37
|
+
}
|
38
|
+
export declare const IUploadNotificationService: import('@univerjs/core').IdentifierDecorator<IUploadNotificationService>;
|
39
|
+
export declare class UploadNotificationService extends Disposable implements IUploadNotificationService, IDisposable {
|
40
|
+
private readonly _visible$;
|
41
|
+
private readonly _state$;
|
42
|
+
private readonly _list$;
|
43
|
+
readonly visible$: Observable<boolean>;
|
44
|
+
readonly state$: Observable<UploadNotificationState>;
|
45
|
+
readonly list$: Observable<ILinkList[]>;
|
46
|
+
private _list;
|
47
|
+
constructor();
|
48
|
+
dispose(): void;
|
49
|
+
show(): void;
|
50
|
+
hide(): void;
|
51
|
+
updateState(state: UploadNotificationState): void;
|
52
|
+
pushLink(link: ILinkList): void;
|
53
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { IWorkbookData, Nullable } from '@univerjs/core';
|
2
|
+
import { IDocumentMeta, ISheetBlock, ISnapshot, IWorkbookMeta, IWorksheetMeta } from '@univerjs/protocol';
|
3
|
+
|
4
|
+
export interface IWorksheetMetaJson extends Omit<IWorksheetMeta, 'originalMeta'> {
|
5
|
+
originalMeta: string;
|
6
|
+
}
|
7
|
+
export interface IWorkbookMetaJson extends Omit<IWorkbookMeta, 'originalMeta' | 'sheets'> {
|
8
|
+
originalMeta: string;
|
9
|
+
sheets: {
|
10
|
+
[key: string]: Partial<IWorksheetMetaJson>;
|
11
|
+
};
|
12
|
+
}
|
13
|
+
export interface IDocumentMetaJson extends Omit<IDocumentMeta, 'originalMeta'> {
|
14
|
+
originalMeta: string;
|
15
|
+
}
|
16
|
+
export interface ISnapshotJson extends Omit<ISnapshot, 'workbook' | 'doc'> {
|
17
|
+
workbook: Partial<IWorkbookMetaJson>;
|
18
|
+
doc: Partial<IDocumentMetaJson>;
|
19
|
+
}
|
20
|
+
export interface ISheetBlockData extends Omit<ISheetBlock, 'data'> {
|
21
|
+
data: string;
|
22
|
+
}
|
23
|
+
export interface ISheetBlockJson {
|
24
|
+
[key: string]: Partial<ISheetBlockData>;
|
25
|
+
}
|
26
|
+
export interface ISnapshotBlockJson {
|
27
|
+
snapshot: ISnapshotJson;
|
28
|
+
sheetBlocks: ISheetBlockJson;
|
29
|
+
}
|
30
|
+
export interface ISnapshotBlockJsonResponse {
|
31
|
+
snapshot: ISnapshot;
|
32
|
+
sheetBlocks: {
|
33
|
+
[key: string]: ISheetBlock;
|
34
|
+
};
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Convert the Uint8Array in the snapshot to a string for easy transmission to the backend
|
38
|
+
* @param snapshot
|
39
|
+
* @returns
|
40
|
+
*/
|
41
|
+
export declare function transformSnapshotMetaToString(snapshot: ISnapshot): Nullable<ISnapshotJson>;
|
42
|
+
/**
|
43
|
+
* Convert the Uint8Array in the sheet block to a string for easy transmission to the backend
|
44
|
+
* @param sheetBlocks
|
45
|
+
* @returns
|
46
|
+
*/
|
47
|
+
export declare function transformSheetBlockMetaToString(sheetBlocks: ISheetBlock[]): ISheetBlockJson;
|
48
|
+
/**
|
49
|
+
* Convert the workbook data to snapshot data
|
50
|
+
* @param workbookData
|
51
|
+
* @returns
|
52
|
+
*/
|
53
|
+
export declare function transformWorkbookDataToSnapshotJson(workbookData: IWorkbookData): Promise<ISnapshotBlockJson>;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { UniverType } from '@univerjs/protocol';
|
2
|
+
|
3
|
+
export declare function downloadFileByURL(url: string, filename: string, fileExt: string): void;
|
4
|
+
/**
|
5
|
+
* Triggers a download of a given File object.
|
6
|
+
*
|
7
|
+
* @param {File} file - The File object to be downloaded.
|
8
|
+
*/
|
9
|
+
export declare function downloadFile(file: File | Blob, filename: string, fileExt: string): void;
|
10
|
+
export declare function getUniverTypeByFile(file: File): UniverType.UNIVER_UNKNOWN | UniverType.UNIVER_DOC | UniverType.UNIVER_SHEET | UniverType.UNIVER_SLIDE;
|
11
|
+
export declare function getUploadFile(types: UniverType[], multiple?: boolean): Promise<FileList | null>;
|
12
|
+
export declare function getFileByURL(url: string): Promise<File | undefined>;
|
13
|
+
export declare function getFileNameFromURL(url: string): string | undefined;
|
14
|
+
export declare function getTextFromURL(url: string): Promise<string | undefined>;
|
15
|
+
export declare function blobToString(blob: Blob): Promise<string>;
|
16
|
+
export declare function bufferToFile(buffer: Uint8Array): File;
|
17
|
+
export declare function replaceType(path: string, type: string): string;
|
18
|
+
export declare function replaceUnitId(path: string, type: string): string;
|
19
|
+
export declare function replaceTaskID(path: string, taskID: string): string;
|
20
|
+
export declare function replaceFileID(path: string, fileID: string): string;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { default as React } from 'react';
|
2
|
+
|
3
|
+
export interface IUploadButton {
|
4
|
+
children?: React.ReactNode;
|
5
|
+
className?: string;
|
6
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
7
|
+
}
|
8
|
+
export declare function UploadButton(props: IUploadButton): React.JSX.Element;
|