Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/zzxming/quill
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming committed Apr 30, 2024
2 parents 204811c + 1635f8f commit 23ebaa8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# [Unreleased]

- Prevent overriding of theme's default toolbar settings mistakenly [#4120](https://github.com/quilljs/quill/pull/4120)
- Improve typings for methods that return a Delta [#4136](https://github.com/quilljs/quill/pull/4136)
- Fix toolbar icons for h3-h6 [#4131](https://github.com/quilljs/quill/pull/4131)

# 2.0.0

Expand Down
10 changes: 5 additions & 5 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class Quill {
name: string,
value: unknown,
source: EmitterSource = Emitter.sources.API,
) {
): Delta {
return modify.call(
this,
() => {
Expand Down Expand Up @@ -557,7 +557,7 @@ class Quill {
embed: string,
value: unknown,
source: EmitterSource = Quill.sources.API,
) {
): Delta {
return modify.call(
this,
() => {
Expand Down Expand Up @@ -647,7 +647,7 @@ class Quill {
return this.emitter.once(...args);
}

removeFormat(index: number, length: number, source?: EmitterSource) {
removeFormat(index: number, length: number, source?: EmitterSource): Delta {
[index, length, , source] = overload(index, length, source);
return modify.call(
this,
Expand Down Expand Up @@ -688,7 +688,7 @@ class Quill {
setContents(
delta: Delta | Op[],
source: EmitterSource = Emitter.sources.API,
) {
): Delta {
return modify.call(
this,
() => {
Expand Down Expand Up @@ -741,7 +741,7 @@ class Quill {
updateContents(
delta: Delta | Op[],
source: EmitterSource = Emitter.sources.API,
) {
): Delta {
return modify.call(
this,
() => {
Expand Down
8 changes: 8 additions & 0 deletions packages/quill/src/ui/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import directionRightToLeftIcon from '../assets/icons/direction-rtl.svg';
import formulaIcon from '../assets/icons/formula.svg';
import headerIcon from '../assets/icons/header.svg';
import header2Icon from '../assets/icons/header-2.svg';
import header3Icon from '../assets/icons/header-3.svg';
import header4Icon from '../assets/icons/header-4.svg';
import header5Icon from '../assets/icons/header-5.svg';
import header6Icon from '../assets/icons/header-6.svg';
import italicIcon from '../assets/icons/italic.svg';
import imageIcon from '../assets/icons/image.svg';
import indentIcon from '../assets/icons/indent.svg';
Expand Down Expand Up @@ -50,6 +54,10 @@ export default {
header: {
'1': headerIcon,
'2': header2Icon,
'3': header3Icon,
'4': header4Icon,
'5': header5Icon,
'6': header6Icon,
},
italic: italicIcon,
image: imageIcon,
Expand Down
36 changes: 22 additions & 14 deletions packages/quill/test/types/quill.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ const quill = new Quill('#editor');
}

{
quill.insertEmbed(10, 'image', 'https://example.com/logo.png');
quill.insertEmbed(10, 'image', 'https://example.com/logo.png', 'api');
assertType<Delta>(
quill.insertEmbed(10, 'image', 'https://example.com/logo.png'),
);
assertType<Delta>(
quill.insertEmbed(10, 'image', 'https://example.com/logo.png', 'api'),
);
}

{
Expand Down Expand Up @@ -74,22 +78,26 @@ const quill = new Quill('#editor');
}

{
quill.updateContents([{ insert: 'Hello World!' }]);
quill.updateContents([{ insert: 'Hello World!' }], 'api');
quill.updateContents(new Delta().insert('Hello World!'));
quill.updateContents(new Delta().insert('Hello World!'), 'api');
assertType<Delta>(quill.updateContents([{ insert: 'Hello World!' }]));
assertType<Delta>(quill.updateContents([{ insert: 'Hello World!' }], 'api'));
assertType<Delta>(quill.updateContents(new Delta().insert('Hello World!')));
assertType<Delta>(
quill.updateContents(new Delta().insert('Hello World!'), 'api'),
);
}

{
quill.setContents([{ insert: 'Hello World!\n' }]);
quill.setContents([{ insert: 'Hello World!\n' }], 'api');
quill.setContents(new Delta().insert('Hello World!\n'));
quill.setContents(new Delta().insert('Hello World!\n'), 'api');
assertType<Delta>(quill.setContents([{ insert: 'Hello World!\n' }]));
assertType<Delta>(quill.setContents([{ insert: 'Hello World!\n' }], 'api'));
assertType<Delta>(quill.setContents(new Delta().insert('Hello World!\n')));
assertType<Delta>(
quill.setContents(new Delta().insert('Hello World!\n'), 'api'),
);
}

{
quill.format('bold', true);
quill.format('bold', true, 'api');
assertType<Delta>(quill.format('bold', true));
assertType<Delta>(quill.format('bold', true, 'api'));
}

{
Expand Down Expand Up @@ -136,8 +144,8 @@ const quill = new Quill('#editor');
}

{
quill.removeFormat(3, 2);
quill.removeFormat(3, 2, 'user');
assertType<Delta>(quill.removeFormat(3, 2));
assertType<Delta>(quill.removeFormat(3, 2, 'user'));
}

{
Expand Down

0 comments on commit 23ebaa8

Please sign in to comment.