feat: moved markdown file with all supported stylings to public and add global keyhandle for markdown easter egg
This commit is contained in:
parent
10314cb09d
commit
188e0e9659
@ -1,7 +1,5 @@
|
|||||||
This is the testing Note for all the Markdown features.
|
This is the testing Note for all the Markdown features.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Heading 1
|
# Heading 1
|
||||||
## Heading 2
|
## Heading 2
|
||||||
### Heading 3
|
### Heading 3
|
38
src/App.vue
38
src/App.vue
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, watchEffect, nextTick} from 'vue'
|
import {ref, watchEffect, nextTick, onMounted, onUnmounted} from 'vue'
|
||||||
import Sidebar from './components/Sidebar.vue'
|
import Sidebar from './components/Sidebar.vue'
|
||||||
import MarkdownEditor from './components/MarkdownEditor.vue'
|
import MarkdownEditor from './components/MarkdownEditor.vue'
|
||||||
|
|
||||||
@ -13,20 +13,48 @@ const active_note = ref(null)
|
|||||||
const input_title = ref('')
|
const input_title = ref('')
|
||||||
const input_content = ref('')
|
const input_content = ref('')
|
||||||
|
|
||||||
|
const loadMarkdown = async () => {
|
||||||
|
// load markdown file
|
||||||
|
const response = await fetch('/data/markdown-test.md')
|
||||||
|
// save the content
|
||||||
|
let markdown = await response.text()
|
||||||
|
// create a new note
|
||||||
|
create_note('Markdown Test Note', markdown)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleKeydown = (event:any) => {
|
||||||
|
if (event.ctrlKey && event.shiftKey && event.key.toLowerCase() === 'm') {
|
||||||
|
// prevent the default behaviour
|
||||||
|
event.preventDefault()
|
||||||
|
// some messages for the easter egg
|
||||||
|
console.log('CTRL + SHIFT + M pressed!')
|
||||||
|
// call the load function
|
||||||
|
loadMarkdown()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => { window.addEventListener('keydown', handleKeydown) })
|
||||||
|
onUnmounted(() => { window.removeEventListener('keydown', handleKeydown) })
|
||||||
|
|
||||||
// find note Index by Id
|
// find note Index by Id
|
||||||
function findNoteIndexById(id:any):any {
|
function findNoteIndexById(id:any):any {
|
||||||
return notes.value.findIndex((note:any) => note.id === id)
|
return notes.value.findIndex((note:any) => note.id === id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create random id
|
||||||
|
function createRandomId():string {
|
||||||
|
return Math.random().toString(36).substring(2,9)
|
||||||
|
}
|
||||||
|
|
||||||
// create note
|
// create note
|
||||||
function create_note() {
|
function create_note(title:string = 'Untitled', content:string = '') {
|
||||||
// generate random id
|
// generate random id
|
||||||
const id = Math.random().toString(36).substring(2,9)
|
const id = createRandomId()
|
||||||
// push new note to notes array
|
// push new note to notes array
|
||||||
notes.value.push({
|
notes.value.push({
|
||||||
id,
|
id,
|
||||||
title: 'Untitled',
|
title: title,
|
||||||
content: ''
|
content: content
|
||||||
})
|
})
|
||||||
// set active note to id
|
// set active note to id
|
||||||
set_active_note(id)
|
set_active_note(id)
|
||||||
|
0
src/assets/.gitkeep
Normal file
0
src/assets/.gitkeep
Normal file
Loading…
x
Reference in New Issue
Block a user