memi-board 0.48.0 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,6 +39,7 @@ const deniedMessage = computed(() => {
|
|
|
39
39
|
const body = ref('')
|
|
40
40
|
const draftId = ref(newCommentId())
|
|
41
41
|
const image = ref<Attachment | null>(null)
|
|
42
|
+
const imageField = ref<InstanceType<typeof MemiBoardCommentImageField> | null>(null)
|
|
42
43
|
const imageBusy = ref(false)
|
|
43
44
|
const submitting = ref(false)
|
|
44
45
|
const error = ref('')
|
|
@@ -116,11 +117,13 @@ onUnmounted(() => {
|
|
|
116
117
|
>
|
|
117
118
|
<UTextarea
|
|
118
119
|
v-model="body"
|
|
120
|
+
@paste="imageField?.handlePaste($event)"
|
|
119
121
|
:placeholder="parent ? t('commentForm.replyTo', { name: parent.authorName || t('common.label.user') }) : t('commentForm.placeholder')"
|
|
120
122
|
:rows="2"
|
|
121
123
|
:maxlength="COMMENT_BODY_MAX_LENGTH"
|
|
122
124
|
/>
|
|
123
125
|
<MemiBoardCommentImageField
|
|
126
|
+
ref="imageField"
|
|
124
127
|
v-model="image"
|
|
125
128
|
:post-id="postId"
|
|
126
129
|
:comment-id="draftId"
|
|
@@ -108,6 +108,22 @@ async function useFile(file: File) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
function handlePaste(event: ClipboardEvent) {
|
|
112
|
+
if (props.disabled || uploading.value) return
|
|
113
|
+
const clipboard = event.clipboardData
|
|
114
|
+
if (!clipboard) return
|
|
115
|
+
const file = Array.from(clipboard.items)
|
|
116
|
+
.filter(item => item.kind === 'file')
|
|
117
|
+
.map(item => item.getAsFile())
|
|
118
|
+
.find((item): item is File => !!item && isCommentImageFile(item))
|
|
119
|
+
?? Array.from(clipboard.files).find(isCommentImageFile)
|
|
120
|
+
if (!file) return
|
|
121
|
+
event.preventDefault()
|
|
122
|
+
void useFile(file)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
defineExpose({ handlePaste })
|
|
126
|
+
|
|
111
127
|
function onInput(event: Event) {
|
|
112
128
|
const input = event.target as HTMLInputElement
|
|
113
129
|
const file = input.files?.[0]
|
|
@@ -43,6 +43,7 @@ const editBody = ref(props.comment.body)
|
|
|
43
43
|
const localBody = ref(props.comment.body)
|
|
44
44
|
const localImage = ref<Attachment | null>(props.comment.images?.[0] ?? null)
|
|
45
45
|
const editImage = ref<Attachment | null>(localImage.value)
|
|
46
|
+
const imageField = ref<InstanceType<typeof MemiBoardCommentImageField> | null>(null)
|
|
46
47
|
const imageBusy = ref(false)
|
|
47
48
|
const localUpdatedAt = ref(props.comment.updatedAt)
|
|
48
49
|
const localBlinded = ref(props.comment.isBlinded ?? false)
|
|
@@ -199,11 +200,13 @@ async function toggleLike() {
|
|
|
199
200
|
>
|
|
200
201
|
<UTextarea
|
|
201
202
|
v-model="editBody"
|
|
203
|
+
@paste="imageField?.handlePaste($event)"
|
|
202
204
|
:rows="2"
|
|
203
205
|
:maxlength="COMMENT_BODY_MAX_LENGTH"
|
|
204
206
|
autofocus
|
|
205
207
|
/>
|
|
206
208
|
<MemiBoardCommentImageField
|
|
209
|
+
ref="imageField"
|
|
207
210
|
v-if="comment.id"
|
|
208
211
|
v-model="editImage"
|
|
209
212
|
:post-id="postId"
|