From 3024a70b75f4f898bb3a02261330ff5e4302f29c Mon Sep 17 00:00:00 2001 From: kudlajz Date: Thu, 11 Jul 2024 19:10:41 +0200 Subject: [PATCH 1/2] Remove useSlateDom from EditorBlock --- .../components/EditorBlock/EditorBlock.tsx | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/slate-editor/src/components/EditorBlock/EditorBlock.tsx b/packages/slate-editor/src/components/EditorBlock/EditorBlock.tsx index 99b91a806..1c80ce0bf 100644 --- a/packages/slate-editor/src/components/EditorBlock/EditorBlock.tsx +++ b/packages/slate-editor/src/components/EditorBlock/EditorBlock.tsx @@ -9,7 +9,7 @@ import type { RenderElementProps } from 'slate-react'; import { ReactEditor, useSelected, useSlateStatic } from 'slate-react'; import { NewParagraphDelimiter } from '#components'; -import { useFunction, useSlateDom } from '#lib'; +import { useFunction } from '#lib'; import { type PopperOptionsContextType, @@ -99,7 +99,6 @@ export const EditorBlock = forwardRef(function ( } const editor = useSlateStatic(); - const editorElement = useSlateDom(editor); const isNodeSelected = useSelected(); const isOnlyBlockSelected = isNodeSelected && @@ -175,26 +174,19 @@ export const EditorBlock = forwardRef(function ( ref={setContainer} style={{ width }} > - {isOnlyBlockSelected && - !loading && - renderMenu && - container && - editorElement && - menuOpen && ( - - {({ updatePosition }) => - renderMenu({ onClose: closeMenu, updatePosition }) - } - - )} + {isOnlyBlockSelected && !loading && renderMenu && container && menuOpen && ( + + {({ updatePosition }) => renderMenu({ onClose: closeMenu, updatePosition })} + + )} {isOverlayEnabled && ( )} From b9650104d604581e9a046aaabe8a26c14cd7237b Mon Sep 17 00:00:00 2001 From: kudlajz Date: Thu, 11 Jul 2024 19:12:42 +0200 Subject: [PATCH 2/2] Memoize enabled extensions --- .../src/modules/editor/Editor.tsx | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/slate-editor/src/modules/editor/Editor.tsx b/packages/slate-editor/src/modules/editor/Editor.tsx index c1220af9b..5938567ca 100644 --- a/packages/slate-editor/src/modules/editor/Editor.tsx +++ b/packages/slate-editor/src/modules/editor/Editor.tsx @@ -141,8 +141,45 @@ export const Editor = forwardRef((props, forwardedRef) = [setFloatingAddMenuOpen], ); - const extensions = Array.from( - getEnabledExtensions({ + const extensions = useMemo( + () => + Array.from( + getEnabledExtensions({ + align, + availableWidth, + onFloatingAddMenuToggle, + withAllowedBlocks, + withAttachments, + withAutoformat, + withBlockquotes, + withButtonBlocks, + withCallouts, + withCoverage, + withCustomNormalization, + withDivider, + withEmbeds, + withFloatingAddMenu, + withGalleries, + withGalleryBookmarks, + withHeadings, + withImages, + withInlineContacts, + withInlineLinks, + withLists, + withPlaceholders, + withPressContacts, + withTextStyling, + withTables, + withUserMentions, + withVariables, + withVideos, + withWebBookmarks, + withStoryEmbeds, + withStoryBookmarks, + withSnippets, + }), + ), + [ align, availableWidth, onFloatingAddMenuToggle, @@ -175,7 +212,7 @@ export const Editor = forwardRef((props, forwardedRef) = withStoryEmbeds, withStoryBookmarks, withSnippets, - }), + ], ); const { editor, onKeyDownList } = useCreateEditor({