From 0249d5644073c0da2df7e7d8d11b9e73d8ecb0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Fri, 26 Apr 2024 19:16:36 +0700 Subject: [PATCH] ShadowDOM support --- core/emitter.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/emitter.js b/core/emitter.js index 94cfe9008b..df1adcd683 100644 --- a/core/emitter.js +++ b/core/emitter.js @@ -8,7 +8,14 @@ const EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click']; if (hasWindow()) { EVENTS.forEach((eventName) => { document.addEventListener(eventName, (...args) => { - Array.from(document.querySelectorAll('.ql-container')).forEach((node) => { + const event = args[0]; + + const target = event?.target; + const shadowRoot = target?.shadowRoot; + + const root = shadowRoot ?? document; + + Array.from(root.querySelectorAll('.ql-container')).forEach((node) => { const quill = instances.get(node); if (quill && quill.emitter) { quill.emitter.handleDOM(...args);