dpu-onlyoffice-react
Version:
React component for OnlyOffice Document Server integration with version history support
222 lines • 5.42 kB
TypeScript
/**
* OnlyOffice Document Editor Configuration
*/
export interface OnlyOfficeConfig {
document: {
fileType: string;
key: string;
title: string;
url: string;
permissions?: {
edit?: boolean;
download?: boolean;
print?: boolean;
review?: boolean;
};
};
documentType: 'word' | 'cell' | 'slide';
editorConfig: {
mode?: 'edit' | 'view';
lang?: string;
location?: string;
customization?: {
uiTheme?: string;
logo?: {
image?: string;
url?: string;
};
about?: {
visible?: boolean;
text?: string;
};
feedback?: {
visible?: boolean;
url?: string;
};
};
user?: {
id: string;
name: string;
group?: string;
};
callbackUrl?: string;
coEditing?: {
mode?: 'fast' | 'strict';
change?: boolean;
};
};
height?: string | number;
width?: string | number;
events?: OnlyOfficeEvents;
}
/**
* OnlyOffice Event Handlers
*/
export interface OnlyOfficeEvents {
onDocumentReady?: (event: any) => void;
onLoadComponentError?: (errorCode: number, errorDescription: string) => void;
onRequestHistory?: (event: any) => void;
onRequestHistoryData?: (event: any) => void;
onRequestHistoryClose?: (event: any) => void;
onRequestClose?: () => void;
onRequestRestore?: (event: any) => void;
onSubmit?: (event: any) => void;
onDocumentStateChange?: (event: any) => void;
onRequestSaveAs?: (event: any) => void;
onRequestInsertImage?: (event: any) => void;
onRequestMailMergeRecipients?: (event: any) => void;
onRequestCompareFile?: (event: any) => void;
onRequestEditRights?: (event: any) => void;
onRequestRename?: (event: any) => void;
onRequestSelectDocument?: (event: any) => void;
}
/**
* Event Data Handlers - User provides data, library handles OnlyOffice integration
*/
export interface DocumentEventHandlers {
onRequestHistory?: (event: any) => void;
onRequestHistoryData?: (event: any) => void;
onRequestHistoryClose?: (event: any) => void;
onRequestRestore?: (event: any) => void;
onRequestClose?: () => void;
onSubmit?: (event: any) => void;
onDocumentReady?: (event: any) => void;
onDocumentStateChange?: (event: any) => void;
onLoadComponentError?: (errorCode: number, errorDescription: string) => void;
onRequestSelectDocument?: (event: any) => void;
onRequestSaveAs?: (event: any) => void;
}
/**
* Document Editor Ref
*/
export interface DocumentEditorRef {
isDocumentLoaded: () => boolean;
getAllKeys: () => Promise<IKeyTemplate[]>;
}
/**
* Document Editor Props
*/
export interface DocumentEditorProps {
config: OnlyOfficeConfig;
editorKey?: number | string;
className?: string;
style?: React.CSSProperties;
onError?: (error: Error) => void;
eventHandlers?: DocumentEventHandlers;
defaultKeys?: IKeyTemplate[];
}
/**
* OnlyOffice Script Loader Options
*/
export interface OnlyOfficeScriptOptions {
scriptUrl?: string;
fallbackUrl?: string;
timeout?: number;
}
/**
* Version History Item
*/
export interface VersionHistoryItem {
version: string;
created: string;
user: {
id: string;
name: string;
};
changes: any;
}
/**
* Version Item for Dialog Selection
*/
export interface VersionItem {
version: string;
created: string;
user: {
id: string;
name: string;
};
key?: string;
serverVersion?: string;
changes?: any;
}
/**
* Requested Document Data from User
*/
export interface RequestedDocumentData {
changesUrl: string;
fileType: string;
key: string;
token: string;
url: string;
version: string;
}
/**
* Editor Requested Document Format
*/
export interface EditorRequestedDocument {
c: string;
fileType: string;
url: string;
token: string;
}
/**
* Error Response Format
*/
export interface ErrorResponse {
error: string;
}
/**
* Requested Document with Error Support
*/
export interface RequestedDocumentWithError {
c?: string;
fileType?: string;
url?: string;
token?: string;
error?: string;
}
/**
* Version History Response
*/
export interface VersionHistoryResponse {
currentVersion: string;
history: VersionItem[];
}
/**
* Key Template
*/
export interface IKeyTemplate {
key: string;
description?: string;
type?: KeyTemplateType;
dataInsertType?: DataInsertType;
}
export declare enum KeyTemplateType {
Single = 0,
MultiLineText = 1,
Table = 2
}
export declare enum DataInsertType {
Text = 0,
Image = 1
}
/**
* Global Window Interface Extension
*/
declare global {
interface Window {
DocsAPI?: {
DocEditor: new (id: string, config: OnlyOfficeConfig) => any;
};
DocEditor?: {
instances?: Record<string, any>;
dialogs?: Record<string, {
versions: VersionItem[];
onVersionSelect: (version: any) => void;
open: boolean;
}>;
};
Api?: any;
}
}
//# sourceMappingURL=index.d.ts.map