Skip to content

Commit a49c6c8

Browse files
Make clearing TypeDoc fields from local storage optional (#2908)
1 parent b53a220 commit a49c6c8

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

site/development/local-storage.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ To enable local storage, use:
1717
`window.TypeDoc.enableLocalStorage();`
1818

1919
**Note:** Local storage is enabled by default.
20+
21+
To disable local storage without clearing it, use:
22+
23+
`window.TypeDoc.disableWritingLocalStorage();`

src/lib/output/themes/default/assets/typedoc/Application.ts

+4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ declare global {
1717
[k: `kind_${number}`]: string;
1818
};
1919
TypeDoc: {
20+
disableWritingLocalStorage: () => void;
2021
disableLocalStorage: () => void;
2122
enableLocalStorage: () => void;
2223
};
2324
}
2425
}
2526

2627
window.TypeDoc ||= {
28+
disableWritingLocalStorage() {
29+
storage.disableWritingLocalStorage();
30+
},
2731
disableLocalStorage: () => {
2832
storage.disable();
2933
},

src/lib/output/themes/default/assets/typedoc/utils/storage.ts

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ try {
2929
export const storage = {
3030
getItem: (key: string) => _storage.getItem(key),
3131
setItem: (key: string, value: string) => _storage.setItem(key, value),
32+
disableWritingLocalStorage() {
33+
_storage = noOpStorageImpl;
34+
},
3235
disable() {
3336
localStorage.clear();
3437
_storage = noOpStorageImpl;

0 commit comments

Comments
 (0)