implement toolbar actions
This commit is contained in:
@@ -19,12 +19,28 @@ watch(notes, () => {
|
||||
|
||||
export const activeNote = ref<Note>()
|
||||
watch(activeNote, () => {
|
||||
if (activeNote.value) useTitle(`${activeNote.value.title} | Contexted`)
|
||||
if (activeNote.value) {
|
||||
useTitle(`${activeNote.value.title} | Contexted`)
|
||||
}
|
||||
})
|
||||
export const setActiveNote = (noteId: string) => {
|
||||
activeNote.value = notes.value.find((note) => note.id === noteId)
|
||||
}
|
||||
|
||||
export const rootNote = computed<Note | undefined>(() => {
|
||||
const rootNote = notes.value.find((note: Note) => note.isRoot)
|
||||
return rootNote
|
||||
})
|
||||
|
||||
export const rootNote = computed<Note | undefined>(() =>
|
||||
notes.value.find((note: Note) => note.isRoot)
|
||||
)
|
||||
export const setRootNote = (noteId: string) => {
|
||||
if (rootNote.value) {
|
||||
const updatedRootNote = { ...baseNotes[rootNote.value.id], isRoot: false }
|
||||
updateNote(updatedRootNote.id, updatedRootNote)
|
||||
}
|
||||
const note = { ...baseNotes[noteId], isRoot: true }
|
||||
updateNote(noteId, note)
|
||||
setActiveNote(noteId)
|
||||
}
|
||||
|
||||
export const setDefaultNotes = (defaultNotes: BaseNote[]) => {
|
||||
defaultNotes.forEach((defaultNote) => {
|
||||
@@ -61,8 +77,8 @@ export const findNotes = (query: string): Note[] => {
|
||||
})
|
||||
}
|
||||
|
||||
export const updateNote = (noteId: string, note: Note) => {
|
||||
const updatedNote: Note = {
|
||||
export const updateNote = (noteId: string, note: BaseNote) => {
|
||||
const updatedNote: BaseNote = {
|
||||
...note,
|
||||
modified: new Date().getTime(),
|
||||
}
|
||||
@@ -82,6 +98,10 @@ export const addNote = (title: string, content: string, goToNote: boolean = fals
|
||||
if (goToNote) activeNote.value = notes.value.find((note) => note.id === newNote.id)
|
||||
}
|
||||
|
||||
export const deleteNote = (noteId: string) => {
|
||||
delete baseNotes[noteId]
|
||||
}
|
||||
|
||||
const getNoteLinksByNoteId = (noteId: string): string[] => {
|
||||
const note = baseNotes[noteId]
|
||||
const regex = /\[\[(.*?)\]\]/g
|
||||
|
||||
Reference in New Issue
Block a user