nhn / tui.editor

🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
http://ui.toast.com/tui-editor
MIT License
16.91k stars 1.72k forks source link

Using the setMarkdown method, you go to events.change twice #3205

Open DIYCCC opened 7 months ago

DIYCCC commented 7 months ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

Add any other context about the problem here. ![Uploading image.png…]()

DIYCCC commented 7 months ago

main code editorRef.current = new Editor({ el: document.querySelector("#editorjs"), events: { change: () => { const a = editorRef.current.getMarkdown(); const bbbbb = editorRef.current.getHTML(); console.log("aaaaaa", a); console.log("inputHistory"); if (!undoOrredoStatus.current) { inputHistory.inputChanged(a); } else { // 由于setMarkdown会进入onchange两次所以坐如下处理 if (undoOrredoStatusNum.current === 1) { undoOrredoStatus.current = false; undoOrredoStatusNum.current = 0; } else { undoOrredoStatusNum.current += 1; } } }, }, });