File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,17 @@ import marked from "../lib/marked";
69
69
70
70
const toastRef = ref (null );
71
71
72
- const state = reactive ({ code: defaultMarkdownText, showPreview: false });
72
+ const STORAGE_TOKEN = Symbol (" reaper-mark" ).toString ();
73
+
74
+ const getDefaultCode = () => {
75
+ const existingCode = localStorage .getItem (STORAGE_TOKEN );
76
+ if (existingCode && existingCode .length ) {
77
+ return existingCode;
78
+ }
79
+ return defaultMarkdownText;
80
+ };
81
+
82
+ const state = reactive ({ code: getDefaultCode (), showPreview: false });
73
83
74
84
onMounted (() => {
75
85
document .addEventListener (" keydown" , shortcutListener .bind (this ));
@@ -98,6 +108,7 @@ function shortcutListener(e) {
98
108
99
109
function handleChange (code ) {
100
110
state .code = code;
111
+ localStorage .setItem (STORAGE_TOKEN , code);
101
112
}
102
113
103
114
async function handleCopyAsHTML () {
You can’t perform that action at this time.
0 commit comments