-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathindex.d.ts
222 lines (185 loc) · 6.47 KB
/
index.d.ts
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// Type definitions for quill-blot-formatter 1.0
// Project: https://github.com/Fandom-OSS/quill-blot-formatter
// Definitions by: Guillaume RODRIGUEZ <https://github.com/guillaume-ro-fr>
export as namespace QuillBlotFormatter;
export interface OverlayOptions {
// classname applied to the overlay element
className: string;
// style applied to overlay element, or null to prevent styles
style?: {};
}
export interface ResizeOptions {
// class name applied to the resize handles
handleClassName: string;
// style applied to resize handles, or null to prevent styles
handleStyle?: {};
}
export interface AlignOptions {
// the name of the attribute for an element that has its alignment changed
attribute: string;
// the aligner does the actual alignment switch
aligner: {
// whether or not the aligner should handle the actual alignment properties
applyStyle: boolean;
};
// icons used for alignment
icons: {
left: string;
center: string;
right: string;
};
// the toolbar so users can change alignments
toolbar: {
// whether or not users can deselect an alignment. it's up to you to set the initial alignment
allowDeselect: boolean;
// class name applied to the root toolbar element
mainClassName: string;
// style applied to root toolbar element, or null to prevent styles
mainStyle?: {};
// class name applied to each button in the toolbar
buttonClassName: string;
/* whether or not to add the selected style to the buttons.
they'll always get the is-selected class */
addButtonSelectStyle: boolean;
// style applied to buttons, or null to prevent styles
buttonStyle?: {};
// style applied to the svgs in the buttons
svgStyle?: {};
};
}
export interface Aligner {
getAlignments(): Alignment[];
isAligned(el: HTMLElement, alignment: Alignment): boolean;
clear(el: HTMLElement): void;
}
export interface Alignment {
name: string;
icon: string;
apply: ((el: HTMLElement) => void);
}
export interface Options {
// the BlotSpecs supported
specs: (typeof BlotSpec)[];
overlay: OverlayOptions;
align: AlignOptions;
resize: ResizeOptions;
}
export const DefaultOptions: Options;
export interface Toolbar {
create(formatter: BlotFormatter, alignmentHelper: Aligner): HTMLElement;
destroy(): void;
getElement(): HTMLElement | null;
}
export class BlotSpec {
formatter: BlotFormatter;
constructor(formatter: BlotFormatter);
init(): void;
getActions(): (typeof Action)[];
getTargetElement(): HTMLElement | null;
getOverlayElement(): HTMLElement | null;
setSelection(): void;
onHide(): void;
}
export class IframeVideoSpec extends UnclickableBlotSpec {
constructor(formatter: BlotFormatter);
}
export class ImageSpec extends BlotSpec {
img?: HTMLElement;
onClick: ((event: MouseEvent) => void);
constructor(formatter: BlotFormatter);
init(): void;
getTargetElement(): HTMLElement | null;
onHide(): void;
}
export class UnclickableBlotSpec extends BlotSpec {
selector: string;
unclickable?: HTMLElement;
nextUnclickable?: HTMLElement;
proxyImage: HTMLImageElement;
repositionProxyImage: ((unclickable: HTMLElement) => void);
onTextChange: (() => void);
onMouseEnter: (() => void);
onProxyImageClick: (() => void);
constructor(formatter: BlotFormatter, selector: string);
init(): void;
getTargetElement(): HTMLElement | null;
getOverlayElement(): HTMLElement | null;
onHide(): void;
createProxyImage(): HTMLElement;
hideProxyImage(): void;
}
export class BlotFormatter {
quill: any;
options: Options;
currentSpec?: BlotSpec;
specs: BlotSpec[];
overlay: HTMLElement;
actions: Action[];
onClick: (() => void);
constructor(quill: any, options?: Options);
show(spec: BlotSpec): void;
hide(): void;
update(): void;
createActions(spec: BlotSpec): void;
destroyActions(): void;
repositionOverlay(): void;
setUserSelect(value: string): void;
}
export class Action {
formatter: BlotFormatter;
constructor(formatter: BlotFormatter);
onCreate(): void;
onDestroy(): void;
onUpdate(): void;
}
export class DeleteAction extends Action {
onKeyUp: ((e: KeyboardEvent) => void);
}
export class ResizeAction extends Action {
topLeftHandle: HTMLElement;
topRightHandle: HTMLElement;
bottomRightHandle: HTMLElement;
bottomLeftHandle: HTMLElement;
dragHandle?: HTMLElement;
dragStartX: number;
preDragWidth: number;
targetRatio: number;
onMouseDown: ((event: MouseEvent) => void);
onDrag: ((event: MouseEvent) => void);
onMouseUp: (() => void);
createHandle(position: string, cursor: string): HTMLElement;
repositionHandles(handleStyle?: {}): void;
setCursor(value: string): void;
}
export class AlignAction extends Action {
toolbar: Toolbar;
aligner: Aligner;
}
export class DefaultAligner implements Aligner {
alignments: { [id: string]: Alignment; };
alignAttribute: string;
applyStyle: boolean;
constructor(options: AlignOptions);
getAlignments(): Alignment[];
clear(el: HTMLElement): void;
isAligned(el: HTMLElement, alignment: Alignment): boolean;
setAlignment(el: HTMLElement, value: string): void;
setStyle(el: HTMLElement, display?: string, float?: string, margin?: string): void;
}
export class DefaultToolbar implements Toolbar {
toolbar?: HTMLElement;
buttons: HTMLElement[];
constructor();
create(formatter: BlotFormatter, aligner: Aligner): HTMLElement;
destroy(): void;
getElement(): HTMLElement | null;
addToolbarStyle(formatter: BlotFormatter, toolbar: HTMLElement): void;
addButtonStyle(button: HTMLElement, index: number, formatter: BlotFormatter): void;
addButtons(formatter: BlotFormatter, toolbar: HTMLElement, aligner: Aligner): void;
preselectButton(button: HTMLElement, alignment: Alignment, formatter: BlotFormatter, aligner: Aligner): void;
onButtonClick(button: HTMLElement, formatter: BlotFormatter, alignment: Alignment, aligner: Aligner): void;
clickButton(button: HTMLElement, alignTarget: HTMLElement, formatter: BlotFormatter, alignment: Alignment, aligner: Aligner): void;
selectButton(formatter: BlotFormatter, button: HTMLElement): void;
deselectButton(formatter: BlotFormatter, button: HTMLElement): void;
}
export default BlotFormatter;