click to add new line
This commit is contained in:
@@ -313,7 +313,6 @@ class NotesAPI {
|
|||||||
}
|
}
|
||||||
getNote(id) {
|
getNote(id) {
|
||||||
const note = this.notesCache.get(id);
|
const note = this.notesCache.get(id);
|
||||||
console.log(id, this.notesCache);
|
|
||||||
return note ? { ...note } : null;
|
return note ? { ...note } : null;
|
||||||
}
|
}
|
||||||
async createNote(metadata = {}, content = "", plainText = "") {
|
async createNote(metadata = {}, content = "", plainText = "") {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const editor = shallowRef()
|
|||||||
const title = ref('')
|
const title = ref('')
|
||||||
const titleInput = ref()
|
const titleInput = ref()
|
||||||
|
|
||||||
const { loadNote, updateNote } = useNotes()
|
const { updateNote } = useNotes()
|
||||||
|
|
||||||
const onUpdate = _debounce(async ({ editor }) => {
|
const onUpdate = _debounce(async ({ editor }) => {
|
||||||
const json = editor.getJSON()
|
const json = editor.getJSON()
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default () => {
|
|||||||
}
|
}
|
||||||
const loadNote = async (id) => {
|
const loadNote = async (id) => {
|
||||||
const api = await getNotesAPI()
|
const api = await getNotesAPI()
|
||||||
console.log(id, api)
|
|
||||||
return api.getNote(id)
|
return api.getNote(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<main class="note layout-block">
|
<main class="note layout-block">
|
||||||
<note-download :title="note.title" :editor="editorRef?.editor" />
|
<note-download :title="editorRef?.title" :editor="editorRef?.editor" />
|
||||||
|
|
||||||
<note-find
|
<note-find
|
||||||
:editor="editorRef?.editor"
|
:editor="editorRef?.editor"
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
@close="findVisible = false"
|
@close="findVisible = false"
|
||||||
/>
|
/>
|
||||||
<note-editor :note="note" ref="editorRef" />
|
<note-editor :note="note" ref="editorRef" />
|
||||||
|
|
||||||
|
<div class="click-target" @click="onTargetClick" />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -36,11 +38,32 @@ watchEffect(() => {
|
|||||||
findVisible.value = !findVisible.value
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
main.note {
|
main.note {
|
||||||
|
min-height: 100%;
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
padding-bottom: 20px;
|
grid-template-rows: auto auto 1fr;
|
||||||
|
display: grid;
|
||||||
|
|
||||||
|
.click-target {
|
||||||
|
cursor: pointer;
|
||||||
|
min-height: 1em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user