I have an inline text editor with react https://github.com/niuware/mui-rte and I want to save my data changed when stop write (or change any style) and a little 1 second delay.
This module have a onSave() method and an onChange method. onSave it's called with a button, and onChange on every change on this textbox (includint onmouseout). There are any function that it's called after last change on text?
I have something like this now, but it's not working, so it call the function on every change, not after last change and 1 second delay.
import React from "react";
import ReactDOM from "react-dom";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import MUIRichTextEditor from "mui-rte";
import InvertColorsIcon from "@mui/icons-material/InvertColors";
let state = false;
const save = (data) => {
console.log(data);
};
const save2 = (data) => {
setTimeout(() => {
console.log(data);
}, 1000);
};
const myTheme = createTheme({
// Set up your custom MUI theme here
});
ReactDOM.render(
<ThemeProvider theme={myTheme}>
<MUIRichTextEditor
label="Type something here..."
onSave={save}
onChange={save2}
inlineToolbar={true}
inlineToolbarControls={["bold", "italic", "my-style", "link"]}
customControls={[
{
name: "my-style",
icon: <InvertColorsIcon />,
type: "inline",
inlineStyle: {
backgroundColor: "black",
color: "white"
}
}
]}
/>
</ThemeProvider>,
document.getElementById("root")
);
Thanks for all
onChangeandonSavehandler.