diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index b869f247..1cadbc58 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -5,10 +5,11 @@ import React, { ReactNode, forwardRef, useCallback, + useEffect, useState, } from 'react'; import { Box, Scroll, Text } from 'folds'; -import { Descendant, Editor, createEditor } from 'slate'; +import { Descendant, Editor, Transforms, createEditor } from 'slate'; import { Slate, Editable, @@ -89,6 +90,12 @@ export const CustomEditor = forwardRef( }, ]); + useEffect(() => { + if (!initialValue?.length) return; + + Transforms.select(editor, Editor.end(editor, [])); + }, [editor, initialValue]); + const renderElement = useCallback( (props: RenderElementProps) => , []