Skip to content

Commit 663a0d7

Browse files
authored
🤖 Merge PR DefinitelyTyped#51981 [Quill] Add the sources map. by @pcorpet
1 parent bbe9c6c commit 663a0d7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

types/quill/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import Delta = require('quill-delta');
2020
* But this would break a lot of existing code as it would require manual discrimination of the union types.
2121
*/
2222
export type DeltaOperation = { insert?: any; delete?: number; retain?: number } & OptionalAttributes;
23+
interface SourceMap {
24+
API: 'api';
25+
SILENT: 'silent';
26+
USER: 'user';
27+
}
2328
export type Sources = 'api' | 'user' | 'silent';
2429

2530
export interface Key {
@@ -134,6 +139,8 @@ export class Quill implements EventEmitter {
134139
update(source?: Sources): void;
135140
updateContents(delta: Delta, source?: Sources): Delta;
136141

142+
static readonly sources: SourceMap;
143+
137144
format(name: string, value: any, source?: Sources): Delta;
138145
formatLine(index: number, length: number, source?: Sources): Delta;
139146
formatLine(index: number, length: number, format: string, value: any, source?: Sources): Delta;

types/quill/quill-tests.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ function test_formatLine3() {
127127
});
128128
}
129129

130+
function test_sources() {
131+
const quillEditor = new Quill('#editor');
132+
quillEditor.formatLine(1, 3, Quill.sources.API);
133+
quillEditor.formatLine(1, 3, Quill.sources.SILENT);
134+
quillEditor.formatLine(1, 3, Quill.sources.USER);
135+
}
136+
130137
function test_insertEmbed() {
131138
const quillEditor = new Quill('#editor');
132139
quillEditor.insertEmbed(10, 'image', 'http://com/images/cloud.png');

0 commit comments

Comments
 (0)