From d5ac3350dfb1f69f0c3591ba5c7e252a07b264fd Mon Sep 17 00:00:00 2001 From: Justin Hopper <29075873+justinbhopper@users.noreply.github.com> Date: Tue, 26 Mar 2024 02:31:11 -0500 Subject: [PATCH] Add support for v1 list attributes (#4082) Co-authored-by: Zihua Li --- CHANGELOG.md | 1 + packages/quill/src/modules/clipboard.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ab9a5b86..7d065aff55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # [Unreleased] +- **Clipboard** Add support for Quill v1 list attributes - Fix overload declarations for `quill.formatText()` and other methods # 2.0.0-rc.4 diff --git a/packages/quill/src/modules/clipboard.ts b/packages/quill/src/modules/clipboard.ts index 34d034bb9b..e4c3f755b5 100644 --- a/packages/quill/src/modules/clipboard.ts +++ b/packages/quill/src/modules/clipboard.ts @@ -539,8 +539,14 @@ function matchIndent(node: Node, delta: Delta, scroll: ScrollBlot) { } function matchList(node: Node, delta: Delta, scroll: ScrollBlot) { - // @ts-expect-error - const list = node.tagName === 'OL' ? 'ordered' : 'bullet'; + const element = node as Element; + let list = element.tagName === 'OL' ? 'ordered' : 'bullet'; + + const checkedAttr = element.getAttribute('data-checked'); + if (checkedAttr) { + list = checkedAttr === 'true' ? 'checked' : 'unchecked'; + } + return applyFormat(delta, 'list', list, scroll); }