This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch feat/1.2.1/ui in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 587148882d545e1633dd4f58a7cc23cb3da32da6 Author: shuai <[email protected]> AuthorDate: Fri Nov 24 15:46:56 2023 +0800 fix: editor img btn props add editor instance --- ui/src/components/Editor/ToolBars/image.tsx | 5 +++-- ui/src/components/Editor/index.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/src/components/Editor/ToolBars/image.tsx b/ui/src/components/Editor/ToolBars/image.tsx index 1cfe1d9b..abb8d3ac 100644 --- a/ui/src/components/Editor/ToolBars/image.tsx +++ b/ui/src/components/Editor/ToolBars/image.tsx @@ -29,8 +29,8 @@ import { IEditorContext } from '../types'; import { uploadImage } from '@/services'; let context: IEditorContext; -const Image = () => { - const [editor, setEditor] = useState<Editor>(null); +const Image = ({ editorContext }) => { + const [editor, setEditor] = useState<Editor>(editorContext); const { t } = useTranslation('translation', { keyPrefix: 'editor' }); const loadingText = `![${t('image.uploading')}...]()`; @@ -197,6 +197,7 @@ const Image = () => { setImageName({ ...imageName, value: '' }); }; useEffect(() => { + console.log('editor img bar======', editor); editor?.on('dragenter', dragenter); editor?.on('dragover', dragover); editor?.on('drop', drop); diff --git a/ui/src/components/Editor/index.tsx b/ui/src/components/Editor/index.tsx index f3295e10..e70663cf 100644 --- a/ui/src/components/Editor/index.tsx +++ b/ui/src/components/Editor/index.tsx @@ -126,7 +126,7 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = ( <Code /> <LinkItem /> <BlockQuote /> - <Image /> + <Image editorContext={editor} /> <Table /> <div className="toolbar-divider" /> <OL />
