From 15f2e8f5a7c0dcc51dfc9828efdf2ca4e282e7a0 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:25:15 +0000 Subject: [PATCH 1/3] Add missing attributor for `Selection` test (#4001) --- packages/quill/test/unit/core/selection.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/quill/test/unit/core/selection.spec.ts b/packages/quill/test/unit/core/selection.spec.ts index 0bc394a57b..f3ba0e98df 100644 --- a/packages/quill/test/unit/core/selection.spec.ts +++ b/packages/quill/test/unit/core/selection.spec.ts @@ -11,7 +11,7 @@ import Italic from '../../../src/formats/italic'; import Strike from '../../../src/formats/strike'; import { ColorStyle } from '../../../src/formats/color'; import { BackgroundStyle } from '../../../src/formats/background'; -import { FontClass } from '../../../src/formats/font'; +import { SizeClass } from '../../../src/formats/size'; const createSelection = (html: string, container = document.body) => { const scroll = createScroll( @@ -25,7 +25,7 @@ const createSelection = (html: string, container = document.body) => { Link, ColorStyle, BackgroundStyle, - FontClass, + SizeClass, ]), container, ); From 9e7ff2adfe823139f7e1a791ce2ead29e06f57b9 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Mon, 12 Feb 2024 03:46:33 +0000 Subject: [PATCH 2/3] Fix toolbar button state not updated in some cases (#2892) Co-authored-by: Alec Gibson --- packages/quill/src/modules/toolbar.ts | 7 +------ packages/quill/test/unit/modules/toolbar.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/quill/src/modules/toolbar.ts b/packages/quill/src/modules/toolbar.ts index 72dec32993..5794bd765d 100644 --- a/packages/quill/src/modules/toolbar.ts +++ b/packages/quill/src/modules/toolbar.ts @@ -61,12 +61,7 @@ class Toolbar extends Module { this.attach(input); }, ); - this.quill.on(Quill.events.EDITOR_CHANGE, (type, range) => { - if (type === Quill.events.SELECTION_CHANGE) { - this.update(range as Range); - } - }); - this.quill.on(Quill.events.SCROLL_OPTIMIZE, () => { + this.quill.on(Quill.events.EDITOR_CHANGE, () => { const [range] = this.quill.selection.getRange(); // quill.getSelection triggers update this.update(range); }); diff --git a/packages/quill/test/unit/modules/toolbar.spec.ts b/packages/quill/test/unit/modules/toolbar.spec.ts index bdae05f9f9..1c81aa3ffd 100644 --- a/packages/quill/test/unit/modules/toolbar.spec.ts +++ b/packages/quill/test/unit/modules/toolbar.spec.ts @@ -236,5 +236,14 @@ describe('Toolbar', () => { expect(centerButton.getAttribute('aria-pressed')).toBe('false'); expect(leftButton.getAttribute('aria-pressed')).toBe('false'); }); + + test('update on format', function () { + const { container, quill } = setup(); + const boldButton = container?.parentNode?.querySelector('button.ql-bold'); + quill.setSelection(1, 2); + expect(boldButton?.classList.contains('ql-active')).toBe(false); + quill.format('bold', true, 'user'); + expect(boldButton?.classList.contains('ql-active')).toBe(true); + }); }); }); From b1b4850f92240dafea2d96c635d39ab490f69527 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Mon, 12 Feb 2024 04:00:55 +0000 Subject: [PATCH 3/3] Narrower `BubbleTheme.tooltip` type (#3732) --- packages/quill/src/themes/bubble.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/quill/src/themes/bubble.ts b/packages/quill/src/themes/bubble.ts index 9f06992b81..85dcb2e4dc 100644 --- a/packages/quill/src/themes/bubble.ts +++ b/packages/quill/src/themes/bubble.ts @@ -106,6 +106,8 @@ class BubbleTooltip extends BaseTooltip { } class BubbleTheme extends BaseTheme { + tooltip: BubbleTooltip; + constructor(quill: Quill, options: ThemeOptions) { if ( options.modules.toolbar != null &&