diff options
Diffstat (limited to 'demo/src/utils/editor-history.util.ts')
| -rw-r--r-- | demo/src/utils/editor-history.util.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/demo/src/utils/editor-history.util.ts b/demo/src/utils/editor-history.util.ts new file mode 100644 index 0000000..33d1916 --- /dev/null +++ b/demo/src/utils/editor-history.util.ts @@ -0,0 +1,17 @@ +const AVRJS8_EDITOR_HISTORY = 'AVRJS8_EDITOR_HISTORY'; + +export class EditorHistoryUtil { + static storeSnippet(codeSnippet: string) { + if (window.localStorage) { + window.localStorage.setItem(AVRJS8_EDITOR_HISTORY, codeSnippet); + } else throw new Error('no localStorage support'); + } + + static clearSnippet() { + localStorage.removeItem(AVRJS8_EDITOR_HISTORY); + } + + static getValue() { + return localStorage.getItem(AVRJS8_EDITOR_HISTORY); + } +} |
