We don't execute document.execCommand() this time, because it is called recursively.
contenteditable div
最近做了个可编辑的div,后期加emoji-picker。
后续发现按enter回车时,隔一个空行时,会多出一个\n,所以当需要只发一条空行时,实际上会发出两条空行。
解决过程: 1、用原生html代码如下:
当空一行的时候,innerHTML正确显示一条,但是innerText会多出一条
其中stack overflow stackoverflow.com/questions/3…
stackoverflow.com/questions/6…
有个人的博客提及到:stephenhaney.com/2020/get-co… (文章日期:2020-11-01)
MDN: developer.mozilla.org/en-US/docs/…
解答解析: