@tldraw/editor
Version:
tldraw infinite canvas SDK (editor).
22 lines (18 loc) • 571 B
text/typescript
import { clearLocalStorage, clearSessionStorage } from '@tldraw/utils'
import { deleteDB } from 'idb'
import { LocalIndexedDb, getAllIndexDbNames } from './LocalIndexedDb'
/**
* Clear the database of all data associated with tldraw.
*
* @public */
export async function hardReset({ shouldReload = true } = {}) {
clearSessionStorage()
for (const instance of LocalIndexedDb.connectedInstances) {
await instance.close()
}
await Promise.all(getAllIndexDbNames().map((db) => deleteDB(db)))
clearLocalStorage()
if (shouldReload) {
window.location.reload()
}
}