From e6254f706a47d0e451d3d40485bf96f819eaa9ab Mon Sep 17 00:00:00 2001 From: Mahmoud Elsayad <36645103+MahmoudElsayad@users.noreply.github.com> Date: Fri, 21 Jun 2024 02:20:53 +0300 Subject: [PATCH] Enable Shadow DOM fix for Safari 17. (#5659) * Enable Safari Shadow DOM fix for Safari 17. * Create weak-files-jam.md * Update changeset. --- .changeset/weak-files-jam.md | 5 +++++ packages/slate-react/src/components/editable.tsx | 15 ++------------- 2 files changed, 7 insertions(+), 13 deletions(-) create mode 100644 .changeset/weak-files-jam.md diff --git a/.changeset/weak-files-jam.md b/.changeset/weak-files-jam.md new file mode 100644 index 000000000..3fd01bf94 --- /dev/null +++ b/.changeset/weak-files-jam.md @@ -0,0 +1,5 @@ +--- +'slate-react': minor +--- + +Enable Shadow DOM fix for all Safari versions. diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 5b1f9b621..ffd6e251d 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -51,7 +51,6 @@ import { IS_WEBKIT, IS_UC_MOBILE, IS_WECHATBROWSER, - IS_SAFARI_LEGACY, } from '../utils/environment' import Hotkeys from '../utils/hotkeys' import { @@ -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() @@ -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]