click to add new line

This commit is contained in:
nicwands
2026-04-02 12:21:35 -04:00
parent 9cd936c256
commit 1fc972a3f0
4 changed files with 26 additions and 5 deletions

View File

@@ -313,7 +313,6 @@ class NotesAPI {
}
getNote(id) {
const note = this.notesCache.get(id);
console.log(id, this.notesCache);
return note ? { ...note } : null;
}
async createNote(metadata = {}, content = "", plainText = "") {

View File

@@ -47,7 +47,7 @@ const editor = shallowRef()
const title = ref('')
const titleInput = ref()
const { loadNote, updateNote } = useNotes()
const { updateNote } = useNotes()
const onUpdate = _debounce(async ({ editor }) => {
const json = editor.getJSON()

View File

@@ -30,7 +30,6 @@ export default () => {
}
const loadNote = async (id) => {
const api = await getNotesAPI()
console.log(id, api)
return api.getNote(id)
}

View File

@@ -1,6 +1,6 @@
<template>
<main class="note layout-block">
<note-download :title="note.title" :editor="editorRef?.editor" />
<note-download :title="editorRef?.title" :editor="editorRef?.editor" />
<note-find
:editor="editorRef?.editor"
@@ -8,6 +8,8 @@
@close="findVisible = false"
/>
<note-editor :note="note" ref="editorRef" />
<div class="click-target" @click="onTargetClick" />
</main>
</template>
@@ -36,11 +38,32 @@ watchEffect(() => {
findVisible.value = !findVisible.value
}
})
const onTargetClick = () => {
const editor = editorRef.value.editor
if (!editor) return
editor.commands.insertContentAt(
editorRef.value.editor.getText().length + 1,
'\n',
)
editor.commands.focus()
editor.commands.setTextSelection(
editorRef.value.editor.getText().length + 1,
)
}
</script>
<style lang="scss">
main.note {
min-height: 100%;
padding-top: 8px;
padding-bottom: 20px;
grid-template-rows: auto auto 1fr;
display: grid;
.click-target {
cursor: pointer;
min-height: 1em;
}
}
</style>