刘光辉
15 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import type { ControlType, DropdownOption, FieldColor } from '../domain/types';
 
export interface InsertTypedControlSpec {
  alias: string;
  color?: FieldColor;
  controlType: Exclude<ControlType, 'text'>;
  defaultChecked: boolean;
  defaultValue: string;
  options: DropdownOption[];
  placeholder: string;
  selectedIndex: number;
  tag: string;
}
 
export interface WriteTextDefaultSpec {
  tag: string;
  value: string;
}
 
export interface OnlyOfficeRange {
  GetText?: () => string;
}
 
export interface OnlyOfficeContentControl {
  AddElement?: (value: unknown, index: number) => unknown;
  GetAlias?: () => string;
  GetInternalId?: () => string;
  GetRange?: () => OnlyOfficeRange;
  GetTag: () => string;
  IsBlockLevel?: () => boolean;
  IsCheckBox?: () => boolean;
  IsComboBox?: () => boolean;
  IsDatePicker?: () => boolean;
  IsDropDownList?: () => boolean;
  RemoveAllElements?: () => unknown;
  SetAlias?: (value: string) => unknown;
  SetAppearance?: (value: string) => unknown;
  SetColor?: (value: unknown) => unknown;
  SetDate?: (value: Date) => unknown;
  SetLock?: (value: string) => unknown;
  SetPlaceholderText?: (value: string) => unknown;
  SetTag?: (value: string) => unknown;
}
 
export interface OnlyOfficeParagraph {
  AddInlineLvlSdt: (control: OnlyOfficeContentControl) => unknown;
  AddText: (value: string) => unknown;
}
 
export interface OnlyOfficeRun {
  AddText?: (value: string) => unknown;
}
 
export interface OnlyOfficeDocument {
  GetAllContentControls: () => OnlyOfficeContentControl[];
  InsertContent?: (items: unknown[], replaceSelection: boolean) => unknown;
  SetTrackRevisions?: (enabled: boolean) => unknown;
}
 
export interface OnlyOfficeApi {
  CreateBlockLvlSdt?: () => OnlyOfficeContentControl;
  CreateCheckBoxContentControl?: (properties: { checked: boolean; checkedSymbol: number; uncheckedSymbol: number }) => OnlyOfficeContentControl;
  CreateComboBoxContentControl?: (options: DropdownOption[], selectedIndex: number) => OnlyOfficeContentControl;
  CreateDatePickerContentControl?: (properties: { format: string; lang: string }) => OnlyOfficeContentControl;
  CreateParagraph: () => OnlyOfficeParagraph;
  CreateRGBColor?: (r: number, g: number, b: number) => unknown;
  CreateRun: () => OnlyOfficeRun;
  GetDocument: () => OnlyOfficeDocument;
}
 
export interface OnlyOfficeScope {
  [key: string]: unknown;
  elnTemplateInsert?: InsertTypedControlSpec;
  elnTemplateList?: Record<string, never>;
  elnTemplateReview?: Record<string, never>;
  elnTemplateTextDefault?: WriteTextDefaultSpec;
}
 
export interface OfficeContentControl {
  Alias?: string;
  ControlType?: ControlType;
  InternalId?: string;
  Tag?: string;
}
 
export type OnlyOfficeCommand = () => string;
 
export interface AscPlugin {
  button?: (id: number) => void;
  callCommand: (command: OnlyOfficeCommand, isClose: boolean, isCalc: boolean, callback: (result: unknown) => void) => boolean | void;
  executeCommand: (command: string, data: string) => unknown;
  executeMethod: (name: string, args: unknown[], callback: (result: unknown) => void) => boolean | void;
  info?: { options?: unknown };
  init?: () => void;
  onThemeChanged?: (theme: unknown) => void;
  onThemeChangedBase: (theme: unknown) => void;
}
 
export interface AscGlobal {
  plugin: AscPlugin;
  scope: OnlyOfficeScope;
}
 
declare global {
  const Api: OnlyOfficeApi;
  const Asc: { scope: OnlyOfficeScope };
 
  interface Window {
    Asc?: AscGlobal;
  }
}