perf: remove unuse code (#2227)

This commit is contained in:
Archer
2024-07-31 15:43:58 +08:00
committed by GitHub
parent 8c7f4a3a30
commit 2fdca621e6
14 changed files with 27 additions and 90 deletions

View File

@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { $getRoot, EditorState, type LexicalEditor } from 'lexical';
import { useCallback, useTransition } from 'react';
import { useCallback } from 'react';
import { editorStateToText } from '../../Textarea/PromptEditor/utils';
import { EditorVariablePickerType } from '../../Textarea/PromptEditor/type';
import Editor from './Editor';
@@ -30,18 +30,14 @@ const HttpInput = ({
}) => {
const [currentValue, setCurrentValue] = React.useState(value);
const [, startSts] = useTransition();
const onChangeInput = useCallback((editorState: EditorState, editor: LexicalEditor) => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
setCurrentValue(text);
onChange?.(text);
}, []);
const onBlurInput = useCallback((editor: LexicalEditor) => {
startSts(() => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
});
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
}, []);
return (

View File

@@ -1,4 +1,4 @@
import { useState, useRef, useTransition, useEffect } from 'react';
import { useState, useRef, useTransition } from 'react';
import { LexicalComposer } from '@lexical/react/LexicalComposer';
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
import { ContentEditable } from '@lexical/react/LexicalContentEditable';

View File

@@ -6,7 +6,7 @@ import MyModal from '../../MyModal';
import { useTranslation } from 'next-i18next';
import { EditorState, type LexicalEditor } from 'lexical';
import { EditorVariableLabelPickerType, EditorVariablePickerType } from './type.d';
import { useCallback, useTransition } from 'react';
import { useCallback } from 'react';
const PromptEditor = ({
showOpenModal = true,
@@ -36,7 +36,6 @@ const PromptEditor = ({
isFlow?: boolean;
}) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const [, startSts] = useTransition();
const { t } = useTranslation();
const onChangeInput = useCallback((editorState: EditorState, editor: LexicalEditor) => {
@@ -44,10 +43,8 @@ const PromptEditor = ({
onChange?.(text);
}, []);
const onBlurInput = useCallback((editor: LexicalEditor) => {
startSts(() => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
});
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
}, []);
return (