Skip to content

Commit 62a9fc6

Browse files
committed
fix(presenter): edit notes via button
1 parent 540802d commit 62a9fc6

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

packages/client/internals/NoteEditor.vue

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { ignorableWatch, onClickOutside } from '@vueuse/core'
3-
import { nextTick, ref, watch } from 'vue'
2+
import { ignorableWatch, onClickOutside, useVModel } from '@vueuse/core'
3+
import { ref, watch, watchEffect } from 'vue'
44
import { currentSlideId } from '../logic/nav'
55
import { useDynamicSlideInfo } from '../logic/note'
66
import NoteDisplay from './NoteDisplay.vue'
@@ -9,6 +9,9 @@ const props = defineProps({
99
class: {
1010
default: '',
1111
},
12+
editing: {
13+
default: false,
14+
},
1215
style: {
1316
default: () => ({}),
1417
},
@@ -17,6 +20,11 @@ const props = defineProps({
1720
},
1821
})
1922
23+
const emit = defineEmits([
24+
'update:editing',
25+
])
26+
const editing = useVModel(props, 'editing', emit, { passive: true })
27+
2028
const { info, update } = useDynamicSlideInfo(currentSlideId)
2129
2230
const note = ref('')
@@ -45,17 +53,11 @@ watch(
4553
)
4654
4755
const input = ref<HTMLTextAreaElement>()
48-
const editing = ref(false)
49-
50-
async function switchNoteEdit(e: MouseEvent) {
51-
if ((e?.target as HTMLElement)?.tagName === 'A')
52-
return
5356
54-
editing.value = true
55-
input.value?.focus()
56-
await nextTick()
57-
input.value?.focus()
58-
}
57+
watchEffect(() => {
58+
if (editing.value)
59+
input.value?.focus()
60+
})
5961
6062
onClickOutside(input, () => {
6163
editing.value = false
@@ -64,13 +66,12 @@ onClickOutside(input, () => {
6466

6567
<template>
6668
<NoteDisplay
67-
v-if="!editing && note"
69+
v-if="!editing"
6870
class="my--4 border-transparent border-2"
69-
:class="props.class"
71+
:class="[props.class, note ? '' : 'opacity-50']"
7072
:style="props.style"
71-
:note="note"
73+
:note="note || placeholder"
7274
:note-html="info?.noteHTML"
73-
@click="switchNoteEdit"
7475
/>
7576
<textarea
7677
v-else

packages/client/internals/Presenter.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ useHead({
3030
title: `Presenter - ${slideTitle}`,
3131
})
3232
33+
const notesEditing = ref(false)
34+
3335
const { timer, resetTimer } = useTimer()
3436
3537
const nextTabElements = ref([])
@@ -143,6 +145,7 @@ onMounted(() => {
143145
<NoteEditor
144146
v-if="__DEV__"
145147
class="w-full max-w-full h-full overflow-auto p-2 lg:p-4"
148+
:editing="notesEditing"
146149
:style="{ fontSize: `${presenterNotesFontSize}em` }"
147150
/>
148151
<NoteStatic
@@ -159,6 +162,13 @@ onMounted(() => {
159162
<HiddenText text="Decrease font size" />
160163
<carbon:zoom-out />
161164
</button>
165+
<button
166+
v-if="__DEV__"
167+
class="slidev-icon-btn" @click="notesEditing = !notesEditing"
168+
>
169+
<HiddenText text="Edit Notes" />
170+
<carbon:edit />
171+
</button>
162172
</div>
163173
</div>
164174
<div class="grid-section bottom">
@@ -212,7 +222,7 @@ onMounted(() => {
212222
}
213223
214224
.grid-container.layout2 {
215-
grid-template-columns: 2fr 1fr;
225+
grid-template-columns: 3fr 2fr;
216226
grid-template-rows: min-content 2fr 1fr min-content;
217227
grid-template-areas:
218228
"top top"

0 commit comments

Comments
 (0)