Skip to content

Commit

Permalink
Memoize enabled extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlajz committed Jul 11, 2024
1 parent 3024a70 commit b965010
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions packages/slate-editor/src/modules/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,45 @@ export const Editor = forwardRef<EditorRef, EditorProps>((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,
Expand Down Expand Up @@ -175,7 +212,7 @@ export const Editor = forwardRef<EditorRef, EditorProps>((props, forwardedRef) =
withStoryEmbeds,
withStoryBookmarks,
withSnippets,
}),
],
);

const { editor, onKeyDownList } = useCreateEditor({
Expand Down

0 comments on commit b965010

Please sign in to comment.