When should the draft box save data in rich text editing

in rich text editing, after the user has edited the content, the user"s data needs to be saved from time to time, using localStorage to save it locally on the client side.

if the user stays on the current editing page, the data is automatically saved every 5 seconds, overwriting and saving with the data in the current editor. If the user accidentally refreshes the page, it will automatically take out the data of the current page just saved and render it to the editor.

however, if the user opens a new editing page, or if the user exits and opens a new editing page, and the user enters the content, you need to create a new draft data in the draft box and then overwrite the update. You can"t overwrite updates directly on previous drafts.

the question is, how do you tell if the user refreshes the edit page or opens a new edit page, whether to create a new draft data or to update it on the existing draft data?

Mar.09,2021

when entering a new editing page, a token value can be randomly generated, such as / article/ {token}, {token: draft} when saving drafts, and token unchanged when the page is refreshed.

when you enter a new page, the token changes. At this time, localStorage determines whether the token is the same. If it is different, you do not have to deal with it

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47646-44c20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47646-44c20.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?