UNPKG

8.79 kBTypeScriptView Raw
1// Type definitions for Summernote v0.8.2
2// Project: http://summernote.org/deep-dive/#initialization-options
3// Definitions by: Wouter Staelens https://github.com/wstaelens/
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6interface SummernoteOptions {
7 airMode?: boolean;
8 buttons?: any;
9 callbacks?: any; // todo
10 codemirror?: CodemirrorOptions;
11 colors?: colorsDef;
12 dialogsInBody?: boolean;
13 dialogsFade?: boolean;
14 direction?: string;
15 disableDragAndDrop?: boolean;
16 disableResizeEditor?: boolean;
17 focus?: boolean;
18 fontNames?: string[];
19 fontNamesIgnoreCheck?: string[];
20 height?: number;
21 hint?: HintOptions;
22 icons?: IconsOptions;
23 insertTableMaxSize?: InsertTableMaxSizeOptions;
24 keyMap?: KeyMapOptions;
25 lang?: string;
26 lineHeights?: string[];
27 minHeight?: number;
28 maxHeight?: number;
29 maximumImageFileSize?: any;
30 modules?: ModuleOptions;
31 popover?: PopoverOptions;
32 placeholder?: string;
33 shortcuts?: boolean;
34 styleTags?: styleTagsOptions[];
35 styleWithSpan?: boolean;
36 tabsize?: number;
37 tableClassName?: string;
38 textareaAutoSync?: boolean;
39 toolbar?: toolbarDef;
40 toolbarContainer?: string;
41 tooltip?: boolean;
42 width?: number;
43}
44
45// callbacks ?
46// https://www.typescriptlang.org/docs/handbook/functions.html#writing-the-function-type
47//type OptionsDef = {
48// callbacks?: {
49// [event: string]: () => void
50// }
51//};
52
53
54type toolbarStyleGroupOptions = 'style' | 'bold' | 'italic' | 'underline' | 'clear';
55type toolbarFontGroupOptions = 'strikethrough' | 'superscript' | 'subscript';
56type toolbarFontsizeGroupOptions = 'fontsize';
57type toolbarColorGroupOptions = 'color';
58type toolbarParaGroupOptions = 'ul' | 'ol' | 'paragraph';
59type toolbarHeightGroupOptions = 'height';
60type toolbarTableGroupOptions = 'table';
61type toolbarInsertGroupOptions = 'link' | 'picture' | 'hr';
62type toolbarViewGroupOptions = 'fullscreen' | 'codeview';
63type toolbarHelpGroupOptions = 'help';
64type toolbarDef = [string, string[]][];
65//type toolbarDef = [
66// ['style', toolbarStyleGroupOptions[]]
67// | ['font', toolbarFontGroupOptions[]]
68// | ['fontsize', toolbarFontsizeGroupOptions[]]
69// | ['color', toolbarColorGroupOptions[]]
70// | ['para', toolbarParaGroupOptions[]]
71// | ['height', toolbarHeightGroupOptions[]]
72// | ['table', toolbarTableGroupOptions[]]
73// | ['insert', toolbarInsertGroupOptions[]]
74// | ['view', toolbarViewGroupOptions[]]
75// | ['help', toolbarHelpGroupOptions[]]
76//];
77
78
79
80type colorsDef = [string[]][];
81type styleTagsOptions = 'p' | 'blockquote' | 'pre' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
82
83interface InsertTableMaxSizeOptions {
84 col: number;
85 row: number;
86}
87
88interface IconsOptions {
89 options?: any; // todo
90}
91
92interface KeyMapOptions {
93 pc?: KeyMapPcOptions;
94 mac?: KeyMapMacOptions;
95}
96
97interface KeyMapPcOptions {
98 options?: any; // todo
99}
100
101interface KeyMapMacOptions {
102 options?: any; // todo
103}
104
105interface HintOptions {
106 words?: string[];
107 mentions?: string[];
108 match: RegExp;
109 search: Function;
110 template?: Function;
111 content?: Function;
112}
113
114interface CodemirrorOptions {
115 mode?: string;
116 htmlNode?: boolean;
117 lineNumbers?: boolean;
118 theme?: string;
119}
120
121type popoverImageOptionsImagesize = 'imageSize100' | 'imageSize50' | 'imageSize25';
122type popoverImageOptionsFloat = 'floatLeft' | 'floatRight' | 'floatNone';
123type popoverImageOptionsRemove = 'removeMedia';
124type popoverImageDef = [
125 ['imagesize', popoverImageOptionsImagesize[]],
126 ['float', popoverImageOptionsFloat[]],
127 ['remove', popoverImageOptionsRemove[]]
128];
129
130type popoverLinkLinkOptions = 'linkDialogShow' | 'unlink';
131type popoverLinkDef = [
132 ['link', popoverLinkLinkOptions[]]
133];
134
135type popoverAirOptionsColor = 'color';
136type popoverAirOptionsFont = 'bold' | 'underline' | 'clear';
137type popoverAirOptionsPara = 'ul' | 'paragraph';
138type popoverAirOptionsTable = 'table';
139type popoverAirOptionsInsert = 'link' | 'picture';
140type popoverAirDef = [
141 ['color', popoverAirOptionsColor],
142 ['font', popoverAirOptionsFont],
143 ['para', popoverAirOptionsPara],
144 ['table', popoverAirOptionsTable],
145 ['insert', popoverAirOptionsInsert]
146];
147
148interface PopoverOptions {
149 image?: popoverImageDef;
150 link?: popoverLinkDef;
151 air?: popoverAirDef;
152}
153
154interface ModuleOptions {
155 options?: any; // todo
156}
157
158interface CreateLinkOptions {
159 text: string;
160 url: string;
161 newWindow: boolean;
162}
163
164interface JQuery {
165 summernote(): JQuery;
166 summernote(command: string): JQuery;
167 summernote(options?: SummernoteOptions): JQuery;
168 summernote(command: string, markupString: string): JQuery
169 summernote(command: string, value: number): JQuery;
170 summernote(command: string, node: Node): JQuery;
171 summernote(command: string, url: string, filename?: (string | Function)): JQuery;
172
173 summernote(command: 'destroy'): JQuery;
174 summernote(command: 'code', markupStr?: string): JQuery;
175 summernote(command: 'editor.pasteHTML' | 'pasteHTML', markup : string): JQuery;
176
177 // Basic API
178 summernote(command: 'editor.createRange' | 'createRange'): JQuery;
179 summernote(command: 'editor.saveRange' | 'saveRange'): JQuery;
180 summernote(command: 'editor.restoreRange' | 'restoreRange'): JQuery;
181 summernote(command: 'editor.undo' | 'undo'): JQuery;
182 summernote(command: 'editor.redo' | 'redo'): JQuery;
183 summernote(command: 'editor.focus' | 'focus'): JQuery;
184 summernote(command: 'editor.isEmpty' | 'isEmpty'): boolean;
185 summernote(command: 'reset'): JQuery;
186 summernote(command: 'disable'): JQuery;
187 summernote(command: 'enable'): JQuery;
188 // Font style API
189 summernote(fontStyle: 'editor.bold' | 'bold'): JQuery;
190 summernote(fontStyle: 'editor.italic' | 'italic'): JQuery;
191 summernote(fontStyle: 'editor.underline' | 'underline'): JQuery;
192 summernote(fontStyle: 'editor.strikethrough' | 'strikethrough'): JQuery;
193 summernote(command: 'editor.superscript' | 'superscript'): JQuery;
194 summernote(command: 'editor.subscript' | 'subscript'): JQuery;
195 summernote(command: 'editor.removeFormat' | 'removeFormat'): JQuery;
196 summernote(command: 'backColor', color: string): JQuery;
197 summernote(command: 'foreColor', color: string): JQuery;
198 summernote(command: 'fontName', fontName: string): JQuery;
199 summernote(command: 'editor.fontSize' | 'fontSize', fontSize: number): JQuery;
200 // Paragraph API
201 summernote(command: 'editor.justifyLeft' | 'justifyLeft'): JQuery;
202 summernote(command: 'editor.justifyRight' | 'justifyRight'): JQuery;
203 summernote(command: 'editor.justifyCenter' | 'justifyCenter'): JQuery;
204 summernote(command: 'editor.justifyFull' | 'justifyFull'): JQuery;
205 summernote(command: 'insertParagraph'): JQuery;
206 summernote(command: 'editor.insertOrderedList' | 'insertOrderedList'): JQuery;
207 summernote(command: 'editor.insertUnorderedList' | 'insertUnorderedList'): JQuery;
208 summernote(command: 'editor.indent' | 'indent'): JQuery;
209 summernote(command: 'editor.outdent' | 'outdent'): JQuery;
210 summernote(command: 'formatPara'): JQuery;
211 summernote(command: 'formatH1'): JQuery;
212 summernote(command: 'formatH2'): JQuery;
213 summernote(command: 'formatH3'): JQuery;
214 summernote(command: 'formatH4'): JQuery;
215 summernote(command: 'formatH5'): JQuery;
216 summernote(command: 'formatH6'): JQuery;
217 // Insertion API
218 summernote(command: 'editor.insertImage' | 'insertImage', url: string, filename?: (string | Function)): JQuery;
219 summernote(command: 'editor.insertNode' | 'insertNode', node: Node): JQuery;
220 summernote(command: 'editor.insertText' | 'insertText', text: string): JQuery;
221 summernote(command: 'createLink', options: CreateLinkOptions): JQuery;
222 summernote(command: 'editor.unlink' | 'unlink'): JQuery;
223 // Callbacks
224 // todo!
225
226 // what about these?
227 // editor.insertImagesOrCallback ??
228 // editor.afterCommand ??
229 // editor.resizeTo ??
230 // editor.resize ??
231 // editor.saveTarget ??
232 // editor.isActivated ??
233 // editor.formatBlock ??
234 // editor.color ??
235 // editor.lineHeight ??
236 // editor.insertTable ??
237 // editor.insertHorizontalRule ??
238 // editor.floatMe ??
239 // editor.removeMedia ??
240 // editor.currentStyle ??
241 // editor.getLinkInfo ??
242 // editor.getSelectedText ??
243
244 // todo: implement keyof in future release of TypeScript: http://stackoverflow.com/a/40843364/187650
245}
246
247declare module "summernote" {
248}
\No newline at end of file