Skip to content

Commit

Permalink
Enable Shadow DOM fix for Safari 17. (#5659)
Browse files Browse the repository at this point in the history
* Enable Safari Shadow DOM fix for Safari 17.

* Create weak-files-jam.md

* Update changeset.
  • Loading branch information
MahmoudElsayad authored Jun 20, 2024
1 parent f3be9f1 commit e6254f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-files-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': minor
---

Enable Shadow DOM fix for all Safari versions.
15 changes: 2 additions & 13 deletions packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
IS_WEBKIT,
IS_UC_MOBILE,
IS_WECHATBROWSER,
IS_SAFARI_LEGACY,
} from '../utils/environment'
import Hotkeys from '../utils/hotkeys'
import {
Expand Down Expand Up @@ -208,12 +207,7 @@ export const Editable = (props: EditableProps) => {
const el = ReactEditor.toDOMNode(editor, editor)
const root = el.getRootNode()

if (
IS_SAFARI_LEGACY &&
!processing.current &&
IS_WEBKIT &&
root instanceof ShadowRoot
) {
if (!processing.current && IS_WEBKIT && root instanceof ShadowRoot) {
processing.current = true

const active = getActiveElement()
Expand Down Expand Up @@ -500,12 +494,7 @@ export const Editable = (props: EditableProps) => {
const el = ReactEditor.toDOMNode(editor, editor)
const root = el.getRootNode()

if (
IS_SAFARI_LEGACY &&
processing?.current &&
IS_WEBKIT &&
root instanceof ShadowRoot
) {
if (processing?.current && IS_WEBKIT && root instanceof ShadowRoot) {
const ranges = event.getTargetRanges()
const range = ranges[0]

Expand Down

0 comments on commit e6254f7

Please sign in to comment.