feat: moved markdown file with all supported stylings to public and add global keyhandle for markdown easter egg

This commit is contained in:
nisch.codes 2025-03-16 19:28:10 +01:00
parent 10314cb09d
commit 188e0e9659
3 changed files with 33 additions and 7 deletions

View File

@ -1,7 +1,5 @@
This is the testing Note for all the Markdown features.
---
# Heading 1
## Heading 2
### Heading 3

View File

@ -1,5 +1,5 @@
<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 MarkdownEditor from './components/MarkdownEditor.vue'
@ -13,20 +13,48 @@ const active_note = ref(null)
const input_title = 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
function findNoteIndexById(id:any):any {
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
function create_note() {
function create_note(title:string = 'Untitled', content:string = '') {
// generate random id
const id = Math.random().toString(36).substring(2,9)
const id = createRandomId()
// push new note to notes array
notes.value.push({
id,
title: 'Untitled',
content: ''
title: title,
content: content
})
// set active note to id
set_active_note(id)

0
src/assets/.gitkeep Normal file
View File