This commit is contained in:
Sidharth Vinod
2021-05-16 13:23:40 +05:30
parent fab404b40b
commit 7704e4dd1d
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import { writable, get } from 'svelte/store';
import { encode, decode } from 'js-base64';
import { toBase64, fromBase64 } from 'js-base64';
import { persist, localStorage } from '@macfja/svelte-persistent-store';
const defaultState: State = {
@@ -23,7 +23,7 @@ export const codeStore = persist(writable(defaultState), localStorage(), 'codeSt
export const loadState = (data: string): void => {
let state: State;
try {
const stateStr = decode(data);
const stateStr = fromBase64(data);
console.log('state from url', stateStr);
state = JSON.parse(stateStr);
} catch (e) {
@@ -51,7 +51,7 @@ export const updateConfig = (config: string, updateEditor: boolean): void => {
export const initURLSubscription = (): void => {
codeStore.subscribe((state: State) => {
window.location.hash = encode(JSON.stringify(state), true);
window.location.hash = toBase64(JSON.stringify(state), true);
});
};
+1 -1
View File
@@ -47,7 +47,7 @@
}
});
});
let insertSvg = function (svgCode, bindFunctions) {};
const insertSvg = (svgCode, bindFunctions) => {};
</script>
<div id="view" class="p-4" class:error class:outOfSync>