UNPKG

2.8 kBTypeScriptView Raw
1import * as React from "react";
2import * as Quill from "quill";
3
4declare namespace ReactQuill {
5 export interface UnprivilegedEditor {
6 getLength(): number;
7 getText(index?: number, length?: number): string;
8 getHTML(): string;
9 getBounds(index: number, length?: number): Quill.BoundsStatic;
10 getSelection(focus?: boolean): Quill.RangeStatic;
11 getContents(index?: number, length?: number): Quill.DeltaStatic;
12 }
13
14 export interface ComponentProps {
15 id?: string;
16 className?: string;
17 theme?: string;
18 style?: React.CSSProperties;
19 readOnly?: boolean;
20 value?: string | Quill.Delta;
21 defaultValue?: string | Quill.Delta;
22 placeholder?: string;
23 tabIndex?: number;
24 bounds?: string | HTMLElement;
25 scrollingContainer?: string | HTMLElement;
26 onChange?: (
27 content: string,
28 delta: Quill.Delta,
29 source: Quill.Sources,
30 editor: UnprivilegedEditor
31 ) => void;
32 onChangeSelection?: (
33 range: Quill.RangeStatic,
34 source: Quill.Sources,
35 editor: UnprivilegedEditor
36 ) => void;
37 onFocus?: (
38 range: Quill.RangeStatic,
39 source: Quill.Sources,
40 editor: UnprivilegedEditor
41 ) => void;
42 onBlur?: (
43 previousRange: Quill.RangeStatic,
44 source: Quill.Sources,
45 editor: UnprivilegedEditor
46 ) => void;
47 onKeyPress?: React.EventHandler<any>;
48 onKeyDown?: React.EventHandler<any>;
49 onKeyUp?: React.EventHandler<any>;
50 formats?: string[];
51 children?: React.ReactElement<any>;
52 modules?: Quill.StringMap;
53 preserveWhitespace?: boolean;
54
55 /** @deprecated
56 * The `toolbar` prop has been deprecated. Use `modules.toolbar` instead.
57 * See: https://github.com/zenoamaro/react-quill#upgrading-to-react-quill-v100.
58 * */
59
60 toolbar?: never;
61 /** @deprecated
62 * The `styles` prop has been deprecated. Use custom stylesheets instead.
63 * See: https://github.com/zenoamaro/react-quill#upgrading-to-react-quill-v100
64 */
65
66 styles?: never;
67 /**
68 * @deprecated
69 * The `pollInterval` property does not have any effect anymore.
70 * You can safely remove it from your props.
71 * See: https://github.com/zenoamaro/react-quill#upgrading-to-react-quill-v100.
72 */
73 pollInterval?: never;
74 }
75
76 export interface Mixin {
77 createEditor(
78 element: HTMLElement,
79 config: Quill.QuillOptionsStatic
80 ): Quill.Quill;
81 hookEditor(editor: Quill.Quill): void;
82 unhookEditor(editor: Quill.Quill): void;
83 setEditorReadOnly(editor: Quill.Quill, value: boolean): void;
84 setEditorContents(editor: Quill.Quill, value: Quill.Delta | string): void;
85 setEditorSelection(editor: Quill.Quill, range: Quill.RangeStatic): void;
86 makeUnprivilegedEditor(editor: Quill.Quill): UnprivilegedEditor;
87 }
88}
89
90export default class ReactQuill extends React.Component<ReactQuill.ComponentProps> {
91 focus(): void;
92 blur(): void;
93 getEditor(): Quill.Quill;
94}
95
96export { Quill } from "quill";