4.7.1-alpha (#1120)

Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
Archer
2024-04-03 18:14:09 +08:00
committed by GitHub
parent 9ae581e09b
commit 8a46372418
76 changed files with 3129 additions and 2104 deletions

View File

@@ -36,7 +36,7 @@ export default function Editor({
hasVariablePlugin?: boolean;
hasDropDownPlugin?: boolean;
variables: EditorVariablePickerType[];
onChange?: (editorState: EditorState) => void;
onChange?: (editorState: EditorState, editor: LexicalEditor) => void;
onBlur?: (editor: LexicalEditor) => void;
value?: string;
currentValue?: string;
@@ -119,9 +119,9 @@ export default function Editor({
<HistoryPlugin />
<FocusPlugin focus={focus} setFocus={setFocus} />
<OnChangePlugin
onChange={(e) => {
onChange={(editorState: EditorState, editor: LexicalEditor) => {
startSts(() => {
onChange?.(e);
onChange?.(editorState, editor);
});
}}
/>

View File

@@ -32,15 +32,13 @@ const HttpInput = ({
const [, startSts] = useTransition();
const onChangeInput = useCallback((editorState: EditorState) => {
const text = editorState.read(() => $getRoot().getTextContent());
const formatValue = text.replaceAll('\n\n', '\n').replaceAll('}}{{', '}} {{');
setCurrentValue(formatValue);
onChange?.(formatValue);
const onChangeInput = useCallback((editorState: EditorState, editor: LexicalEditor) => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onChange?.(text);
}, []);
const onBlurInput = useCallback((editor: LexicalEditor) => {
startSts(() => {
const text = editorStateToText(editor).replaceAll('\n\n', '\n').replaceAll('}}{{', '}} {{');
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
});
}, []);