diff --git a/src/App.vue b/src/App.vue index d0c3c87..4e50490 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,30 +2,30 @@ import NavBar from './components/NavBar.vue'; import CodeMirror from './components/CodeMirror.vue'; import { - onMounted, - onUnmounted, - reactive, - ref, - watchEffect, + onMounted, + onUnmounted, + reactive, + ref, + watchEffect, } from 'vue'; import setupPreview from './composables/preview'; import { backup, restore, templateData } from './composables/storage'; let fileData = restore(); if (!fileData || typeof fileData !== 'object') { - fileData = templateData; - backup(fileData); + fileData = templateData; + backup(fileData); } const files = reactive(Object.assign({}, fileData)); function backupFiles(e) { - if (e.ctrlKey && e.key.toLowerCase() === 's') { - e.preventDefault(); - console.log('backing up files...'); - backup(files); - console.log('backup was successful...'); - } + if (e.ctrlKey && e.key.toLowerCase() === 's') { + e.preventDefault(); + console.log('backing up files...'); + backup(files); + console.log('backup was successful...'); + } } const showPreview = ref(true); @@ -33,92 +33,63 @@ const showPreview = ref(true); const currentTab = ref('index.html'); function setTab(to) { - currentTab.value = to; + currentTab.value = to; } function getLang(filename) { - const ext = filename.split('.').pop(); - if (ext === 'js') return 'javascript'; - return ext; + const ext = filename.split('.').pop(); + if (ext === 'js') return 'javascript'; + return ext; } function setCode(file, doc) { - files[file] = doc; + files[file] = doc; } const iframe = ref(); onMounted(() => { - watchEffect(() => { - setupPreview(iframe.value, files['index.html'], files['style.css'], files['main.js']); - }) + watchEffect(() => { + setupPreview(iframe.value, files['index.html'], files['style.css'], files['main.js']); + }) - document.addEventListener('keydown', backupFiles, false); + document.addEventListener('keydown', backupFiles, false); }); onUnmounted(() => { - document.removeEventListener('keydown', backupFiles, false); + document.removeEventListener('keydown', backupFiles, false); }); diff --git a/src/components/CodeMirror.vue b/src/components/CodeMirror.vue index 6314c96..157f3dc 100644 --- a/src/components/CodeMirror.vue +++ b/src/components/CodeMirror.vue @@ -1,5 +1,5 @@