click to add new line
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -30,7 +30,6 @@ export default () => {
|
||||
}
|
||||
const loadNote = async (id) => {
|
||||
const api = await getNotesAPI()
|
||||
console.log(id, api)
|
||||
return api.getNote(id)
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user