From 4d0bfb730912b88d0e5561670b5c7dd234f2d343 Mon Sep 17 00:00:00 2001 From: Raul P <794190+ra00l@users.noreply.github.com> Date: Tue, 7 May 2024 14:28:53 +0300 Subject: [PATCH] fix: Content editable in shadow dom fix #685, #906 --- src/Tribute.js | 4 ++++ src/TributeRange.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Tribute.js b/src/Tribute.js index cfb06eb5..2c8e7f14 100755 --- a/src/Tribute.js +++ b/src/Tribute.js @@ -9,6 +9,7 @@ class Tribute { values = null, loadingItemTemplate = null, iframe = null, + shadowRoot = null, selectClass = "highlight", containerClass = "tribute-container", itemClass = "", @@ -58,6 +59,9 @@ class Tribute { // is it wrapped in an iframe iframe: iframe, + // is it wrapped in a web component + shadowRoot: shadowRoot, + // class applied to selected item selectClass: selectClass, diff --git a/src/TributeRange.js b/src/TributeRange.js index e0709fef..e827a8c0 100644 --- a/src/TributeRange.js +++ b/src/TributeRange.js @@ -183,6 +183,10 @@ class TributeRange { return this.tribute.collection.iframe.contentWindow.getSelection() } + if (this.tribute.collection[0].shadowRoot) { + return this.tribute.collection[0].shadowRoot.getSelection() + } + return window.getSelection() }