🐛 Fix editor won't reset after posted post
This commit is contained in:
parent
1664fa62c4
commit
2b4ffb6811
@ -25,37 +25,18 @@
|
|||||||
You are editing a post with alias <b class="font-mono">{{ editor.related.edit_to?.alias }}</b>
|
You are editing a post with alias <b class="font-mono">{{ editor.related.edit_to?.alias }}</b>
|
||||||
</v-alert>
|
</v-alert>
|
||||||
|
|
||||||
<v-textarea
|
<v-textarea required class="mb-3" variant="outlined" label="Content"
|
||||||
required
|
hint="The content supports markdown syntax" v-model="data.content" @paste="pasteMedia" />
|
||||||
class="mb-3"
|
|
||||||
variant="outlined"
|
|
||||||
label="Content"
|
|
||||||
hint="The content supports markdown syntax"
|
|
||||||
v-model="data.content"
|
|
||||||
@paste="pasteMedia"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<v-expansion-panels>
|
<v-expansion-panels>
|
||||||
<v-expansion-panel title="Brief describe">
|
<v-expansion-panel title="Brief describe">
|
||||||
<template #text>
|
<template #text>
|
||||||
<div class="mt-1">
|
<div class="mt-1">
|
||||||
<v-text-field
|
<v-text-field required variant="solo-filled" density="comfortable" label="Title" :loading="reverting"
|
||||||
required
|
v-model="data.title" />
|
||||||
variant="solo-filled"
|
|
||||||
density="comfortable"
|
|
||||||
label="Title"
|
|
||||||
:loading="reverting"
|
|
||||||
v-model="data.title"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<v-textarea
|
<v-textarea required auto-grow variant="solo-filled" density="comfortable" label="Description"
|
||||||
required
|
v-model="data.description" />
|
||||||
auto-grow
|
|
||||||
variant="solo-filled"
|
|
||||||
density="comfortable"
|
|
||||||
label="Description"
|
|
||||||
v-model="data.description"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</v-expansion-panel>
|
</v-expansion-panel>
|
||||||
@ -66,7 +47,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<p class="text-xs">Your content will visible for public at</p>
|
<p class="text-xs">Your content will visible for public at</p>
|
||||||
<p class="text-lg font-medium">
|
<p class="text-lg font-medium">
|
||||||
{{ data.published_at ? new Date(data.published_at).toLocaleString() : new Date().toLocaleString() }}
|
{{ data.published_at ? new Date(data.published_at).toLocaleString() : new Date().toLocaleString()
|
||||||
|
}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<v-btn size="small" icon="mdi-pencil" variant="text" @click="dialogs.plan = true" />
|
<v-btn size="small" icon="mdi-pencil" variant="text" @click="dialogs.plan = true" />
|
||||||
@ -149,7 +131,7 @@ const data = ref<any>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const currentRealm = computed(() => {
|
const currentRealm = computed(() => {
|
||||||
if(data.value.realm_id) {
|
if (data.value.realm_id) {
|
||||||
return realms.available.find((e: any) => e.id === data.value.realm_id)
|
return realms.available.find((e: any) => e.id === data.value.realm_id)
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
@ -187,16 +169,29 @@ async function postArticle(evt: SubmitEvent) {
|
|||||||
})
|
})
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
form.reset()
|
|
||||||
router.push({ name: "posts.details.articles", params: { alias: data.alias } })
|
|
||||||
success.value = true
|
success.value = true
|
||||||
editor.show.article = false
|
editor.show.article = false
|
||||||
|
|
||||||
|
resetEditor(form)
|
||||||
|
router.push({ name: "posts.details.articles", params: { alias: data.alias } })
|
||||||
} else {
|
} else {
|
||||||
error.value = await res.text()
|
error.value = await res.text()
|
||||||
}
|
}
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetEditor(target: HTMLFormElement) {
|
||||||
|
target.reset()
|
||||||
|
data.value = {
|
||||||
|
title: "",
|
||||||
|
content: "",
|
||||||
|
description: "",
|
||||||
|
realm_id: null,
|
||||||
|
published_at: null,
|
||||||
|
attachments: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const media = ref<any>(null)
|
const media = ref<any>(null)
|
||||||
|
|
||||||
function pasteMedia(evt: ClipboardEvent) {
|
function pasteMedia(evt: ClipboardEvent) {
|
||||||
|
@ -6,40 +6,20 @@
|
|||||||
You are editing a post with alias <b class="font-mono">{{ editor.related.edit_to?.alias }}</b>
|
You are editing a post with alias <b class="font-mono">{{ editor.related.edit_to?.alias }}</b>
|
||||||
</v-alert>
|
</v-alert>
|
||||||
|
|
||||||
<v-textarea
|
<v-textarea required persistent-counter variant="outlined" label="What's happened?!" counter="1024"
|
||||||
required
|
v-model="data.content" @paste="pasteMedia" />
|
||||||
persistent-counter
|
|
||||||
variant="outlined"
|
|
||||||
label="What's happened?!"
|
|
||||||
counter="1024"
|
|
||||||
v-model="data.content"
|
|
||||||
@paste="pasteMedia"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="flex mt-[-18px]">
|
<div class="flex mt-[-18px]">
|
||||||
<v-tooltip text="Planned publish" location="start">
|
<v-tooltip text="Planned publish" location="start">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<v-btn
|
<v-btn v-bind="props" type="button" variant="text" icon="mdi-calendar" size="small"
|
||||||
v-bind="props"
|
@click="dialogs.plan = true" />
|
||||||
type="button"
|
|
||||||
variant="text"
|
|
||||||
icon="mdi-calendar"
|
|
||||||
size="small"
|
|
||||||
@click="dialogs.plan = true"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
<v-tooltip text="Media" location="start">
|
<v-tooltip text="Media" location="start">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<v-btn
|
<v-btn v-bind="props" icon class="text-none" type="button" variant="text" size="small"
|
||||||
v-bind="props"
|
@click="dialogs.media = true">
|
||||||
icon
|
|
||||||
class="text-none"
|
|
||||||
type="button"
|
|
||||||
variant="text"
|
|
||||||
size="small"
|
|
||||||
@click="dialogs.media = true"
|
|
||||||
>
|
|
||||||
<v-badge v-if="data.attachments.length > 0" :content="data.attachments.length">
|
<v-badge v-if="data.attachments.length > 0" :content="data.attachments.length">
|
||||||
<v-icon icon="mdi-camera" />
|
<v-icon icon="mdi-camera" />
|
||||||
</v-badge>
|
</v-badge>
|
||||||
@ -92,8 +72,8 @@ import { getAtk } from "@/stores/userinfo"
|
|||||||
import { reactive, ref, watch } from "vue"
|
import { reactive, ref, watch } from "vue"
|
||||||
import { useRoute, useRouter } from "vue-router"
|
import { useRoute, useRouter } from "vue-router"
|
||||||
import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue"
|
import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue"
|
||||||
import Media from "@/components/publish/parts/Media.vue"
|
|
||||||
import PublishArea from "@/components/publish/parts/PublishArea.vue"
|
import PublishArea from "@/components/publish/parts/PublishArea.vue"
|
||||||
|
import Media from "@/components/publish/parts/Media.vue"
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const editor = useEditor()
|
const editor = useEditor()
|
||||||
@ -135,10 +115,11 @@ async function postMoment(evt: SubmitEvent) {
|
|||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
})
|
})
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
form.reset()
|
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
success.value = true
|
success.value = true
|
||||||
editor.show.moment = false
|
editor.show.moment = false
|
||||||
|
|
||||||
|
resetEditor(form)
|
||||||
router.push({ name: "posts.details.moments", params: { alias: data.alias } })
|
router.push({ name: "posts.details.moments", params: { alias: data.alias } })
|
||||||
} else {
|
} else {
|
||||||
error.value = await res.text()
|
error.value = await res.text()
|
||||||
@ -146,6 +127,16 @@ async function postMoment(evt: SubmitEvent) {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetEditor(target: HTMLFormElement) {
|
||||||
|
target.reset()
|
||||||
|
data.value = {
|
||||||
|
content: "",
|
||||||
|
realm_id: null,
|
||||||
|
published_at: null,
|
||||||
|
attachments: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const media = ref<any>(null)
|
const media = ref<any>(null)
|
||||||
|
|
||||||
function pasteMedia(evt: ClipboardEvent) {
|
function pasteMedia(evt: ClipboardEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user