Fix: about section editor (#7287)

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
pull/7634/head
Arindam Biswas 2023-03-09 18:36:37 +05:30 committed by GitHub
parent 2ddada49f9
commit c374f4fa20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -2,7 +2,6 @@ import { CodeHighlightNode, CodeNode } from "@lexical/code";
import { AutoLinkNode, LinkNode } from "@lexical/link"; import { AutoLinkNode, LinkNode } from "@lexical/link";
import { ListItemNode, ListNode } from "@lexical/list"; import { ListItemNode, ListNode } from "@lexical/list";
import { TRANSFORMERS } from "@lexical/markdown"; import { TRANSFORMERS } from "@lexical/markdown";
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
import { LexicalComposer } from "@lexical/react/LexicalComposer"; import { LexicalComposer } from "@lexical/react/LexicalComposer";
import { ContentEditable } from "@lexical/react/LexicalContentEditable"; import { ContentEditable } from "@lexical/react/LexicalContentEditable";
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin"; import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
@ -71,7 +70,6 @@ export const Editor = (props: TextEditorProps) => {
contentEditable={<ContentEditable style={{ height: props.height }} className="editor-input" />} contentEditable={<ContentEditable style={{ height: props.height }} className="editor-input" />}
placeholder={<div className="-mt-11 p-3 text-sm text-gray-300">{props.placeholder || ""}</div>} placeholder={<div className="-mt-11 p-3 text-sm text-gray-300">{props.placeholder || ""}</div>}
/> />
<AutoFocusPlugin />
<ListPlugin /> <ListPlugin />
<LinkPlugin /> <LinkPlugin />
<AutoLinkPlugin /> <AutoLinkPlugin />

View File

@ -349,11 +349,12 @@ export default function ToolbarPlugin(props: TextEditorProps) {
$getRoot().select(); $getRoot().select();
$insertNodes(nodes); $insertNodes(nodes);
editor.registerUpdateListener(({ editorState }) => { editor.registerUpdateListener(({ editorState, prevEditorState }) => {
editorState.read(() => { editorState.read(() => {
const textInHtml = $generateHtmlFromNodes(editor); const textInHtml = $generateHtmlFromNodes(editor);
props.setText(textInHtml); props.setText(textInHtml);
}); });
if (!prevEditorState._selection) editor.blur();
}); });
}); });
}, []); }, []);