fix: draft performance in mixed input
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
|||||||
createTrailingBlockPlugin,
|
createTrailingBlockPlugin,
|
||||||
createNodeIdPlugin,
|
createNodeIdPlugin,
|
||||||
createParagraphPlugin,
|
createParagraphPlugin,
|
||||||
// createImagePlugin,
|
|
||||||
createSoftBreakPlugin,
|
createSoftBreakPlugin,
|
||||||
// createComboboxPlugin,
|
// createComboboxPlugin,
|
||||||
createMentionPlugin,
|
createMentionPlugin,
|
||||||
@@ -21,7 +20,6 @@ import {
|
|||||||
createPlugins,
|
createPlugins,
|
||||||
ELEMENT_PARAGRAPH,
|
ELEMENT_PARAGRAPH,
|
||||||
getPlateEditorRef,
|
getPlateEditorRef,
|
||||||
|
|
||||||
// usePlateEditorRef,
|
// usePlateEditorRef,
|
||||||
// ELEMENT_IMAGE,
|
// ELEMENT_IMAGE,
|
||||||
MentionCombobox,
|
MentionCombobox,
|
||||||
@@ -51,7 +49,6 @@ const Plugins = ({
|
|||||||
const enableMentions = members.length > 0;
|
const enableMentions = members.length > 0;
|
||||||
const filesRef = useRef([]);
|
const filesRef = useRef([]);
|
||||||
const contactData = useSelector((store) => store.contacts.byId);
|
const contactData = useSelector((store) => store.contacts.byId);
|
||||||
const [originalValue, setOriginalValue] = useState(initialValue);
|
|
||||||
const [msgs, setMsgs] = useState([]);
|
const [msgs, setMsgs] = useState([]);
|
||||||
const [cmdKey, setCmdKey] = useState(false);
|
const [cmdKey, setCmdKey] = useState(false);
|
||||||
const editableRef = useRef(null);
|
const editableRef = useRef(null);
|
||||||
@@ -79,12 +76,13 @@ const Plugins = ({
|
|||||||
window.addEventListener("paste", handlePasteEvent);
|
window.addEventListener("paste", handlePasteEvent);
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("paste", handlePasteEvent);
|
window.removeEventListener("paste", handlePasteEvent);
|
||||||
|
const plateEditor = getPlateEditorRef(`${TEXT_EDITOR_PREFIX}_${id}`);
|
||||||
|
if (plateEditor && updateDraft) {
|
||||||
|
updateDraft(plateEditor.children);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// window.addEventListener("paste")
|
// window.addEventListener("paste")
|
||||||
}, []);
|
}, [id, updateDraft]);
|
||||||
useEffect(() => {
|
|
||||||
updateDraft(originalValue);
|
|
||||||
}, [originalValue]);
|
|
||||||
|
|
||||||
useKey(
|
useKey(
|
||||||
"Enter",
|
"Enter",
|
||||||
@@ -154,7 +152,6 @@ const Plugins = ({
|
|||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
async (val) => {
|
async (val) => {
|
||||||
setOriginalValue(val);
|
|
||||||
console.log("tmps changed", val);
|
console.log("tmps changed", val);
|
||||||
const tmps = [];
|
const tmps = [];
|
||||||
const getMixedText = (children) => {
|
const getMixedText = (children) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user