Ghost형 툴바·초안 자동 저장·발행 모달, private 제거, 미디어 모달 통합, 발행일·수정일 표시 설정과 DB 마이그레이션 025·026을 반영한다. Co-authored-by: Cursor <cursoragent@cursor.com>
1698 lines
64 KiB
Vue
1698 lines
64 KiB
Vue
<script setup>
|
|
import {
|
|
isAdminPostDraftPlaceholderSlug,
|
|
toAdminPostFormTitle,
|
|
toAdminPostStoredTitle
|
|
} from '../../lib/admin-post-title.js'
|
|
import { normalizeMarkdownContent } from '../../lib/markdown-content-normalizer.js'
|
|
|
|
const props = defineProps({
|
|
initialPost: {
|
|
type: Object,
|
|
default: () => ({})
|
|
},
|
|
saving: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
/** 초안 서버 자동 저장 중(부모 PUT 진행) */
|
|
autoSaving: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
canViewPost: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
publicUrl: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
deleting: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
showDelete: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
})
|
|
|
|
const emit = defineEmits(['submit', 'preview', 'delete', 'autosave'])
|
|
|
|
const autosaveStoragePrefix = 'SORI_ADMIN_POST_AUTOSAVE'
|
|
let draftPersistTimer = null
|
|
const slugTouched = ref(
|
|
Boolean(props.initialPost.slug)
|
|
&& !isAdminPostDraftPlaceholderSlug(props.initialPost.slug)
|
|
)
|
|
const blockEditor = ref(null)
|
|
const mediaItems = ref([])
|
|
const isMediaPickerOpen = ref(false)
|
|
const mediaPickerTarget = ref('featuredImage')
|
|
const isLoadingMedia = ref(false)
|
|
const isUploadingFeaturedImage = ref(false)
|
|
const isSettingsOpen = ref(true)
|
|
const tagInput = ref('')
|
|
const isTagInputComposing = ref(false)
|
|
const isTitleInputComposing = ref(false)
|
|
const activeMediaPickerTab = ref('upload')
|
|
const selectedMediaPickerUrl = ref('')
|
|
const savedPostSnapshot = ref('')
|
|
const isPublishModalOpen = ref(false)
|
|
const isUnpublishModalOpen = ref(false)
|
|
const publishStatus = ref('draft')
|
|
const publishTiming = ref('now')
|
|
const scheduledPublishAt = ref('')
|
|
const publishModalExpandedSection = ref(null)
|
|
|
|
/**
|
|
* ISO 날짜를 datetime-local 입력값으로 변환
|
|
* @param {string} value - ISO 날짜 문자열
|
|
* @returns {string} datetime-local 입력값
|
|
*/
|
|
function toDateTimeLocalValue(value) {
|
|
if (!value) {
|
|
return ''
|
|
}
|
|
|
|
const date = new Date(value)
|
|
|
|
if (Number.isNaN(date.getTime())) {
|
|
return ''
|
|
}
|
|
|
|
const offsetDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000)
|
|
|
|
return offsetDate.toISOString().slice(0, 16)
|
|
}
|
|
|
|
/**
|
|
* datetime-local 입력값을 ISO 문자열로 변환
|
|
* @param {string} value - datetime-local 입력값
|
|
* @returns {string | null} ISO 날짜 문자열
|
|
*/
|
|
function toIsoDateTime(value) {
|
|
if (!value) {
|
|
return null
|
|
}
|
|
|
|
const date = new Date(value)
|
|
|
|
if (Number.isNaN(date.getTime())) {
|
|
return null
|
|
}
|
|
|
|
return date.toISOString()
|
|
}
|
|
|
|
/**
|
|
* datetime-local 값을 날짜·시간 필드로 분리
|
|
* @param {string} value - datetime-local 문자열
|
|
* @returns {{ date: string, time: string }}
|
|
*/
|
|
function splitDateTimeLocal(value) {
|
|
if (!value || !value.includes('T')) {
|
|
return { date: '', time: '' }
|
|
}
|
|
const [date, time] = value.split('T')
|
|
return { date: date || '', time: (time || '').slice(0, 5) }
|
|
}
|
|
|
|
/**
|
|
* 날짜·시간 필드를 datetime-local 문자열로 합침
|
|
* @param {string} date - YYYY-MM-DD
|
|
* @param {string} time - HH:mm
|
|
* @returns {string}
|
|
*/
|
|
function joinDateTimeLocal(date, time) {
|
|
if (!date) {
|
|
return ''
|
|
}
|
|
return `${date}T${time || '00:00'}`
|
|
}
|
|
|
|
const form = reactive({
|
|
title: toAdminPostFormTitle(props.initialPost.title),
|
|
slug: props.initialPost.slug || '',
|
|
excerpt: props.initialPost.excerpt || '',
|
|
content: normalizeMarkdownContent(props.initialPost.content),
|
|
featuredImage: props.initialPost.featuredImage || '',
|
|
isFeatured: Boolean(props.initialPost.isFeatured),
|
|
noindex: Boolean(props.initialPost.noindex),
|
|
status: props.initialPost.status === 'private' ? 'draft' : (props.initialPost.status || 'draft'),
|
|
publishedAt: toDateTimeLocalValue(props.initialPost.publishedAt),
|
|
tagsText: props.initialPost.tags?.join(', ') || ''
|
|
})
|
|
|
|
const autosaveKey = computed(() => `${autosaveStoragePrefix}:${props.initialPost.id || 'new'}`)
|
|
const postUrlLabel = computed(() => form.slug || toSlug(form.title) || '')
|
|
const postUrlHint = computed(() => props.publicUrl || (postUrlLabel.value ? `/post/${postUrlLabel.value}/` : '/post/'))
|
|
|
|
/**
|
|
* 한글 음절 1자를 영문 표기로 변환
|
|
* @param {string} char - 변환할 문자
|
|
* @returns {string} 영문 표기
|
|
*/
|
|
const romanizeHangulSyllable = (char) => {
|
|
const syllableCode = char.charCodeAt(0)
|
|
const hangulBase = 0xac00
|
|
const hangulLast = 0xd7a3
|
|
if (syllableCode < hangulBase || syllableCode > hangulLast) {
|
|
return char
|
|
}
|
|
|
|
const choseong = ['g', 'kk', 'n', 'd', 'tt', 'r', 'm', 'b', 'pp', 's', 'ss', '', 'j', 'jj', 'ch', 'k', 't', 'p', 'h']
|
|
const jungseong = ['a', 'ae', 'ya', 'yae', 'eo', 'e', 'yeo', 'ye', 'o', 'wa', 'wae', 'oe', 'yo', 'u', 'wo', 'we', 'wi', 'yu', 'eu', 'ui', 'i']
|
|
const jongseong = ['', 'k', 'k', 'ks', 'n', 'nj', 'nh', 't', 'l', 'lk', 'lm', 'lb', 'ls', 'lt', 'lp', 'lh', 'm', 'p', 'ps', 't', 't', 'ng', 't', 't', 'k', 't', 'p', 'h']
|
|
|
|
const offset = syllableCode - hangulBase
|
|
const choseongIndex = Math.floor(offset / 588)
|
|
const jungseongIndex = Math.floor((offset % 588) / 28)
|
|
const jongseongIndex = offset % 28
|
|
|
|
return `${choseong[choseongIndex]}${jungseong[jungseongIndex]}${jongseong[jongseongIndex]}`
|
|
}
|
|
|
|
/**
|
|
* 문자열을 URL 슬러그로 변환
|
|
* @param {string} value - 원본 문자열
|
|
* @returns {string} 슬러그
|
|
*/
|
|
const toSlug = (value) => value
|
|
.normalize('NFC')
|
|
.split('')
|
|
.map((char) => romanizeHangulSyllable(char))
|
|
.join('')
|
|
.trim()
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9\s-]/g, '')
|
|
.replace(/\s+/g, '-')
|
|
.replace(/-+/g, '-')
|
|
.replace(/^-|-$/g, '')
|
|
|
|
/**
|
|
* 게시물 태그 입력 토큰 정규화(한글 유지, 공백은 하이픈으로)
|
|
* @param {string} value - 원본 문자열
|
|
* @returns {string} 정규화된 태그 문자열
|
|
*/
|
|
const normalizeTagToken = (value) => {
|
|
const raw = String(value).normalize('NFC').trim().toLowerCase()
|
|
if (!raw) {
|
|
return ''
|
|
}
|
|
|
|
return raw
|
|
.replace(/\s+/g, '-')
|
|
.replace(/[^a-z0-9가-힣-]+/g, '')
|
|
.replace(/-+/g, '-')
|
|
.replace(/^-|-$/g, '')
|
|
}
|
|
|
|
watch(() => form.title, (title) => {
|
|
if (!slugTouched.value) {
|
|
const next = toSlug(title)
|
|
if (next) {
|
|
form.slug = next
|
|
}
|
|
}
|
|
})
|
|
|
|
/**
|
|
* 슬러그 직접 입력 상태 표시
|
|
* @returns {void}
|
|
*/
|
|
const touchSlug = () => {
|
|
slugTouched.value = true
|
|
form.slug = toSlug(form.slug)
|
|
}
|
|
|
|
/**
|
|
* 쉼표 구분 태그 문자열을 토큰 배열로 변환
|
|
* @param {string} value - 태그 입력 문자열
|
|
* @returns {Array<string>} 태그 토큰 목록
|
|
*/
|
|
const parseTags = (value) => {
|
|
const seen = new Set()
|
|
const out = []
|
|
|
|
for (const part of value.split(',')) {
|
|
const tag = normalizeTagToken(part)
|
|
if (!tag) {
|
|
continue
|
|
}
|
|
const dedupeKey = tag.toLowerCase()
|
|
if (seen.has(dedupeKey)) {
|
|
continue
|
|
}
|
|
seen.add(dedupeKey)
|
|
out.push(tag)
|
|
}
|
|
|
|
return out
|
|
}
|
|
|
|
const selectedTags = computed(() => parseTags(form.tagsText))
|
|
|
|
/**
|
|
* 예약 발행 여부 확인
|
|
* @returns {boolean} 예약 발행 여부
|
|
*/
|
|
const isScheduledPost = () => {
|
|
const publishedAt = toIsoDateTime(form.publishedAt)
|
|
|
|
return form.status === 'published' && Boolean(publishedAt) && new Date(publishedAt) > new Date()
|
|
}
|
|
|
|
/** 초안 편집 UI(예약 발행 제외) */
|
|
const isDraftLike = computed(() => form.status === 'draft' && !isScheduledPost())
|
|
|
|
/** 발행됨(즉시 공개) */
|
|
const isPublishedLive = computed(() => form.status === 'published' && !isScheduledPost())
|
|
|
|
/**
|
|
* 서버에 반영된 게시 형태(툴바·자동 저장 분기 전용)
|
|
* @param {Object} post - 게시물
|
|
* @returns {'draft' | 'publishedLive' | 'scheduled'}
|
|
*/
|
|
const getPersistedPublishKind = (post) => {
|
|
if (!post?.id) {
|
|
return 'draft'
|
|
}
|
|
const st = post.status === 'private' ? 'draft' : post.status
|
|
if (st !== 'published') {
|
|
return 'draft'
|
|
}
|
|
const pa = post.publishedAt
|
|
if (pa && new Date(pa) > new Date()) {
|
|
return 'scheduled'
|
|
}
|
|
return 'publishedLive'
|
|
}
|
|
|
|
/** 마지막으로 서버와 맞춘 게시 형태 */
|
|
const persistedPublishKind = ref(getPersistedPublishKind(props.initialPost))
|
|
|
|
watch(
|
|
() => props.initialPost,
|
|
(post) => {
|
|
persistedPublishKind.value = getPersistedPublishKind(post)
|
|
},
|
|
{ deep: true }
|
|
)
|
|
|
|
/** 툴바·상태줄에 즉시 발행으로 표시할지(서버 기준이거나 초안 글에서 폼만 발행으로 바뀐 경우) */
|
|
const displayPublishedLive = computed(() =>
|
|
persistedPublishKind.value === 'publishedLive'
|
|
|| (persistedPublishKind.value === 'draft' && isPublishedLive.value))
|
|
|
|
/** 툴바·상태줄에 예약으로 표시할지 */
|
|
const displayScheduled = computed(() =>
|
|
persistedPublishKind.value === 'scheduled'
|
|
|| (persistedPublishKind.value === 'draft' && isScheduledPost()))
|
|
|
|
/**
|
|
* 발행 모달에 표시할 게시 상태 요약 문구
|
|
* @returns {string} 요약 문구
|
|
*/
|
|
const publishStatusSummaryLabel = computed(() => {
|
|
if (publishStatus.value === 'published') {
|
|
return '발행'
|
|
}
|
|
|
|
return '초안'
|
|
})
|
|
|
|
/**
|
|
* 발행 모달에 표시할 발행 시점 요약 문구
|
|
* @returns {string} 요약 문구
|
|
*/
|
|
const publishTimingSummaryLabel = computed(() => {
|
|
if (publishTiming.value === 'now') {
|
|
return '지금 바로'
|
|
}
|
|
|
|
const raw = scheduledPublishAt.value
|
|
|
|
if (!raw) {
|
|
return '예약'
|
|
}
|
|
|
|
const date = new Date(raw)
|
|
|
|
if (Number.isNaN(date.getTime())) {
|
|
return '예약'
|
|
}
|
|
|
|
return new Intl.DateTimeFormat('ko-KR', {
|
|
dateStyle: 'medium',
|
|
timeStyle: 'short'
|
|
}).format(date)
|
|
})
|
|
|
|
/**
|
|
* 게시물 입력값 생성
|
|
* @returns {Object} 게시물 입력값
|
|
*/
|
|
const createPostPayload = () => {
|
|
const publishedAt = form.status === 'published'
|
|
? toIsoDateTime(form.publishedAt) || props.initialPost.publishedAt || new Date().toISOString()
|
|
: null
|
|
|
|
return {
|
|
title: toAdminPostStoredTitle(form.title),
|
|
slug: toSlug(form.slug || form.title),
|
|
excerpt: form.excerpt.trim(),
|
|
content: normalizeMarkdownContent(form.content),
|
|
featuredImage: form.featuredImage.trim() || null,
|
|
isFeatured: form.isFeatured,
|
|
seoTitle: toAdminPostStoredTitle(form.title),
|
|
seoDescription: form.excerpt.trim(),
|
|
canonicalUrl: '',
|
|
noindex: form.noindex,
|
|
ogImage: null,
|
|
status: form.status,
|
|
publishedAt,
|
|
tags: selectedTags.value
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 현재 게시물 입력값을 문자열로 직렬화한다.
|
|
* @returns {string} 직렬화된 게시물 입력값
|
|
*/
|
|
const serializePostPayload = () => JSON.stringify(createPostPayload())
|
|
|
|
const hasUnsavedPostChanges = computed(() => serializePostPayload() !== savedPostSnapshot.value)
|
|
|
|
const serializedPostFingerprint = computed(() => serializePostPayload())
|
|
|
|
/**
|
|
* 초안 자동 저장을 서버에 보낼 수 있는지(슬러그 유효, 제목은 비어 있으면 서버에서 `(제목 없음)`으로 보정)
|
|
* @returns {boolean}
|
|
*/
|
|
const canPersistDraftPayload = computed(() => {
|
|
const s = toSlug(form.slug || form.title)
|
|
return Boolean(s)
|
|
})
|
|
|
|
/**
|
|
* 서버 자동 저장 대상: 폼이 초안이고, 서버에도 아직 초안으로만 반영된 글(발행·예약 글의 미저장 사이드바 변경은 제외)
|
|
* @returns {boolean}
|
|
*/
|
|
const shouldServerAutosaveDraft = computed(() => {
|
|
if (!isDraftLike.value) {
|
|
return false
|
|
}
|
|
return persistedPublishKind.value === 'draft'
|
|
})
|
|
|
|
/**
|
|
* 발행·예약 글만 미저장 이탈을 막는다(초안은 서버 자동 저장·이탈 직전 플러시로 처리)
|
|
* @returns {boolean}
|
|
*/
|
|
const isRouteLeaveDirty = computed(() => {
|
|
if (!hasUnsavedPostChanges.value) {
|
|
return false
|
|
}
|
|
if (persistedPublishKind.value === 'publishedLive' || persistedPublishKind.value === 'scheduled') {
|
|
return true
|
|
}
|
|
return false
|
|
})
|
|
|
|
/**
|
|
* 툴바 왼쪽 초안 상태 문구(Draft / Saving… / Draft - Saved)
|
|
* @returns {string|null} null이면 다른 상태 UI 사용
|
|
*/
|
|
const headerDraftStatusText = computed(() => {
|
|
if (persistedPublishKind.value !== 'draft') {
|
|
return null
|
|
}
|
|
if (displayPublishedLive.value || displayScheduled.value) {
|
|
return null
|
|
}
|
|
const persisting = props.saving || props.autoSaving
|
|
if (persisting) {
|
|
return 'Saving...'
|
|
}
|
|
if (hasUnsavedPostChanges.value) {
|
|
return 'Draft'
|
|
}
|
|
return props.initialPost?.id ? 'Draft - Saved' : 'Draft'
|
|
})
|
|
|
|
/**
|
|
* 예약 발행일 툴팁(영문 한 줄)
|
|
* @returns {string}
|
|
*/
|
|
const scheduledStatusTooltip = computed(() => {
|
|
const iso = toIsoDateTime(form.publishedAt)
|
|
if (!iso) {
|
|
return ''
|
|
}
|
|
const d = new Date(iso)
|
|
if (Number.isNaN(d.getTime())) {
|
|
return ''
|
|
}
|
|
const line = d.toLocaleString('en-GB', {
|
|
dateStyle: 'long',
|
|
timeStyle: 'short'
|
|
})
|
|
return `Scheduled to be published on ${line}`
|
|
})
|
|
|
|
/**
|
|
* 레거시 로컬 자동 저장 키 제거
|
|
* @returns {void}
|
|
*/
|
|
const clearAutosaveLocal = () => {
|
|
if (!import.meta.client) {
|
|
return
|
|
}
|
|
localStorage.removeItem(autosaveKey.value)
|
|
}
|
|
|
|
const {
|
|
isUnsavedModalOpen,
|
|
stayOnUnsavedPage,
|
|
leaveUnsavedPage,
|
|
allowNextRouteLeave
|
|
} = useAdminUnsavedChangesGuard(isRouteLeaveDirty, {
|
|
onLeaveConfirmed: clearAutosaveLocal
|
|
})
|
|
|
|
/**
|
|
* 미디어 라이브러리 목록 조회
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const fetchMediaItems = async () => {
|
|
isLoadingMedia.value = true
|
|
|
|
try {
|
|
mediaItems.value = await $fetch('/admin/api/media')
|
|
} finally {
|
|
isLoadingMedia.value = false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 선택 창 열기
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const openMediaPicker = async (target = 'featuredImage') => {
|
|
mediaPickerTarget.value = target
|
|
activeMediaPickerTab.value = 'upload'
|
|
selectedMediaPickerUrl.value = form[target] || ''
|
|
isMediaPickerOpen.value = true
|
|
await fetchMediaItems()
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 선택 창 닫기
|
|
* @returns {void}
|
|
*/
|
|
const closeMediaPicker = () => {
|
|
isMediaPickerOpen.value = false
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 선택 상태 변경
|
|
* @param {Object} item - 미디어 항목
|
|
* @returns {void}
|
|
*/
|
|
const selectPickedImage = (item) => {
|
|
selectedMediaPickerUrl.value = item.url
|
|
}
|
|
|
|
/**
|
|
* 선택한 대표 이미지 적용
|
|
* @returns {void}
|
|
*/
|
|
const applyPickedImage = () => {
|
|
if (!selectedMediaPickerUrl.value) {
|
|
return
|
|
}
|
|
|
|
form[mediaPickerTarget.value] = selectedMediaPickerUrl.value
|
|
closeMediaPicker()
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 삭제
|
|
* @returns {void}
|
|
*/
|
|
const removeFeaturedImage = () => {
|
|
form.featuredImage = ''
|
|
}
|
|
|
|
/**
|
|
* 태그 입력값을 배지 목록에 추가
|
|
* @returns {void}
|
|
*/
|
|
const addTagFromInput = () => {
|
|
const nextTag = normalizeTagToken(tagInput.value)
|
|
|
|
if (!nextTag) {
|
|
tagInput.value = ''
|
|
return
|
|
}
|
|
|
|
form.tagsText = [...new Set([...selectedTags.value, nextTag])].join(', ')
|
|
tagInput.value = ''
|
|
}
|
|
|
|
/**
|
|
* 태그 배지 삭제
|
|
* @param {string} tag - 삭제할 태그
|
|
* @returns {void}
|
|
*/
|
|
const removeTag = (tag) => {
|
|
form.tagsText = selectedTags.value.filter((item) => item !== tag).join(', ')
|
|
}
|
|
|
|
/**
|
|
* 태그 입력 키 처리
|
|
* @param {KeyboardEvent} event - 키보드 이벤트
|
|
* @returns {void}
|
|
*/
|
|
const handleTagKeydown = (event) => {
|
|
if (event.isComposing || isTagInputComposing.value || event.keyCode === 229) {
|
|
return
|
|
}
|
|
|
|
if (event.key === 'Enter' || event.key === ',') {
|
|
event.preventDefault()
|
|
addTagFromInput()
|
|
return
|
|
}
|
|
|
|
if (event.key === 'Backspace' && !tagInput.value && selectedTags.value.length) {
|
|
event.preventDefault()
|
|
removeTag(selectedTags.value.at(-1))
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 파일 업로드
|
|
* @param {File} file - 업로드 파일
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const uploadFeaturedImageFile = async (file) => {
|
|
const formData = new FormData()
|
|
formData.append('files', file)
|
|
isUploadingFeaturedImage.value = true
|
|
|
|
try {
|
|
const result = await $fetch('/admin/api/uploads', {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
selectedMediaPickerUrl.value = result.files?.[0]?.url || ''
|
|
await fetchMediaItems()
|
|
activeMediaPickerTab.value = 'library'
|
|
} finally {
|
|
isUploadingFeaturedImage.value = false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 파일 입력 처리
|
|
* @param {Event} event - 파일 입력 이벤트
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const uploadFeaturedImage = async (event) => {
|
|
const files = event.target.files
|
|
|
|
if (!files?.length) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
await uploadFeaturedImageFile(files[0])
|
|
} finally {
|
|
event.target.value = ''
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 대표 이미지 드롭 업로드
|
|
* @param {DragEvent} event - 드롭 이벤트
|
|
* @returns {Promise<void>}
|
|
*/
|
|
const dropFeaturedImage = async (event) => {
|
|
const files = event.dataTransfer?.files
|
|
|
|
if (!files?.length) {
|
|
return
|
|
}
|
|
|
|
await uploadFeaturedImageFile(files[0])
|
|
}
|
|
|
|
/**
|
|
* 제목 입력 후 본문 에디터로 이동
|
|
* @param {KeyboardEvent} event - 키보드 이벤트
|
|
* @returns {void}
|
|
*/
|
|
const focusContentEditor = (event) => {
|
|
if (event?.isComposing || isTitleInputComposing.value || event?.keyCode === 229) {
|
|
return
|
|
}
|
|
|
|
event?.preventDefault()
|
|
blockEditor.value?.focusFirstBlock()
|
|
}
|
|
|
|
/**
|
|
* 게시물 입력값 제출
|
|
* @returns {void}
|
|
*/
|
|
const submitPost = () => {
|
|
isPublishModalOpen.value = false
|
|
isUnpublishModalOpen.value = false
|
|
emit('submit', createPostPayload())
|
|
}
|
|
|
|
/**
|
|
* 발행·예약 글 본문 수정분을 서버에 반영(Update)
|
|
* @returns {void}
|
|
*/
|
|
const requestToolbarUpdate = () => {
|
|
emit('submit', createPostPayload())
|
|
}
|
|
|
|
/**
|
|
* 발행 취소·예약 취소 확인 화면을 연다.
|
|
* @returns {void}
|
|
*/
|
|
const openUnpublishModal = () => {
|
|
isUnpublishModalOpen.value = true
|
|
}
|
|
|
|
/**
|
|
* 발행 취소·예약 취소 확인 화면을 닫는다.
|
|
* @returns {void}
|
|
*/
|
|
const closeUnpublishModal = () => {
|
|
isUnpublishModalOpen.value = false
|
|
}
|
|
|
|
/**
|
|
* 발행 취소 또는 예약 취소(초안으로 되돌림)를 확정한다.
|
|
* @returns {void}
|
|
*/
|
|
const confirmUnpublishOrUnschedule = () => {
|
|
form.status = 'draft'
|
|
form.publishedAt = ''
|
|
submitPost()
|
|
}
|
|
|
|
/**
|
|
* 게시물 미리보기 요청
|
|
* @returns {void}
|
|
*/
|
|
const previewPost = () => {
|
|
emit('preview', createPostPayload())
|
|
}
|
|
|
|
/**
|
|
* 게시물 삭제 요청
|
|
* @returns {void}
|
|
*/
|
|
const deletePost = () => {
|
|
emit('delete')
|
|
}
|
|
|
|
/**
|
|
* 설정 패널 표시 상태 전환
|
|
* @returns {void}
|
|
*/
|
|
const toggleSettingsPanel = () => {
|
|
isSettingsOpen.value = !isSettingsOpen.value
|
|
}
|
|
|
|
/**
|
|
* 발행 모달을 현재 폼 상태로 초기화한다.
|
|
* @returns {void}
|
|
*/
|
|
const syncPublishModalStateFromForm = () => {
|
|
if (persistedPublishKind.value === 'draft') {
|
|
publishStatus.value = 'published'
|
|
publishTiming.value = 'now'
|
|
scheduledPublishAt.value = toDateTimeLocalValue(new Date().toISOString())
|
|
return
|
|
}
|
|
|
|
publishStatus.value = form.status === 'published' ? 'published' : 'draft'
|
|
scheduledPublishAt.value = form.publishedAt || toDateTimeLocalValue(new Date(Date.now() + 3600000).toISOString())
|
|
publishTiming.value = isScheduledPost() ? 'schedule' : 'now'
|
|
}
|
|
|
|
/**
|
|
* 발행 모달 열기
|
|
* @returns {void}
|
|
*/
|
|
const openPublishModal = () => {
|
|
syncPublishModalStateFromForm()
|
|
publishModalExpandedSection.value = null
|
|
isPublishModalOpen.value = true
|
|
}
|
|
|
|
/**
|
|
* 발행 모달 닫기
|
|
* @returns {void}
|
|
*/
|
|
const closePublishModal = () => {
|
|
isPublishModalOpen.value = false
|
|
}
|
|
|
|
/**
|
|
* 발행 모달에서 선택한 값을 폼에 반영
|
|
* @returns {void}
|
|
*/
|
|
const applyPublishSelectionToForm = () => {
|
|
form.status = publishStatus.value
|
|
|
|
if (publishStatus.value !== 'published') {
|
|
form.publishedAt = ''
|
|
return
|
|
}
|
|
|
|
if (publishTiming.value === 'schedule') {
|
|
form.publishedAt = scheduledPublishAt.value || toDateTimeLocalValue(new Date(Date.now() + 3600000).toISOString())
|
|
return
|
|
}
|
|
|
|
form.publishedAt = toDateTimeLocalValue(new Date().toISOString())
|
|
}
|
|
|
|
/**
|
|
* 발행 모달에서 최종 저장/발행 확정
|
|
* @returns {void}
|
|
*/
|
|
const submitFromPublishModal = () => {
|
|
applyPublishSelectionToForm()
|
|
submitPost()
|
|
}
|
|
|
|
/**
|
|
* 발행 모달에서 설정 행 펼침을 토글한다.
|
|
* @param {'status' | 'timing'} section - 펼칠 행
|
|
* @returns {void}
|
|
*/
|
|
const togglePublishModalSection = (section) => {
|
|
publishModalExpandedSection.value =
|
|
publishModalExpandedSection.value === section ? null : section
|
|
}
|
|
|
|
/**
|
|
* 발행 모달에서 게시 상태를 선택한다.
|
|
* @param {'published' | 'draft'} status - 선택 상태
|
|
* @returns {void}
|
|
*/
|
|
const selectPublishStatus = (status) => {
|
|
publishStatus.value = status
|
|
publishModalExpandedSection.value = null
|
|
|
|
if (status !== 'published') {
|
|
publishTiming.value = 'now'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 발행 모달에서 발행 시점을 선택한다.
|
|
* @param {'now' | 'schedule'} timing - 즉시 또는 예약
|
|
* @returns {void}
|
|
*/
|
|
const selectPublishTiming = (timing) => {
|
|
publishTiming.value = timing
|
|
|
|
if (timing === 'now') {
|
|
publishModalExpandedSection.value = null
|
|
} else if (!scheduledPublishAt.value) {
|
|
scheduledPublishAt.value = toDateTimeLocalValue(new Date(Date.now() + 3600000).toISOString())
|
|
}
|
|
}
|
|
|
|
/** 설정 패널 발행 날짜(YYYY-MM-DD) */
|
|
const settingsPublishDate = computed({
|
|
get: () => splitDateTimeLocal(form.publishedAt).date,
|
|
set: (date) => {
|
|
const { time } = splitDateTimeLocal(form.publishedAt)
|
|
form.publishedAt = joinDateTimeLocal(date, time || '12:00')
|
|
}
|
|
})
|
|
|
|
/** 설정 패널 발행 시각(HH:mm) */
|
|
const settingsPublishTime = computed({
|
|
get: () => splitDateTimeLocal(form.publishedAt).time,
|
|
set: (time) => {
|
|
const { date } = splitDateTimeLocal(form.publishedAt)
|
|
const baseDate = date || new Date().toISOString().slice(0, 10)
|
|
form.publishedAt = joinDateTimeLocal(baseDate, time || '12:00')
|
|
}
|
|
})
|
|
|
|
/** 발행 모달 예약 날짜 */
|
|
const modalScheduleDate = computed({
|
|
get: () => splitDateTimeLocal(scheduledPublishAt.value).date,
|
|
set: (date) => {
|
|
const { time } = splitDateTimeLocal(scheduledPublishAt.value)
|
|
scheduledPublishAt.value = joinDateTimeLocal(date, time || '12:00')
|
|
}
|
|
})
|
|
|
|
/** 발행 모달 예약 시각 */
|
|
const modalScheduleTime = computed({
|
|
get: () => splitDateTimeLocal(scheduledPublishAt.value).time,
|
|
set: (time) => {
|
|
const { date } = splitDateTimeLocal(scheduledPublishAt.value)
|
|
const baseDate = date || new Date().toISOString().slice(0, 10)
|
|
scheduledPublishAt.value = joinDateTimeLocal(baseDate, time || '12:00')
|
|
}
|
|
})
|
|
|
|
/** 발행 취소 화면에 표시할 서버 반영 발행 시각 문구 */
|
|
const unpublishPersistedPublishedLabel = computed(() => {
|
|
const iso = props.initialPost?.publishedAt
|
|
if (!iso) {
|
|
return ''
|
|
}
|
|
const d = new Date(iso)
|
|
if (Number.isNaN(d.getTime())) {
|
|
return ''
|
|
}
|
|
return new Intl.DateTimeFormat('ko-KR', {
|
|
dateStyle: 'long',
|
|
timeStyle: 'short'
|
|
}).format(d)
|
|
})
|
|
|
|
/** 발행 취소 화면 제목(즉시 발행 / 예약) */
|
|
const unpublishModalKind = computed(() => (
|
|
persistedPublishKind.value === 'scheduled' ? 'scheduled' : 'published'
|
|
))
|
|
|
|
/**
|
|
* 현재 입력값을 저장 완료 기준점으로 표시한다.
|
|
* @returns {void}
|
|
*/
|
|
const markSaved = () => {
|
|
savedPostSnapshot.value = serializePostPayload()
|
|
}
|
|
|
|
/**
|
|
* 디바운스 타이머를 취소하고, 즉시 서버로 보낼 초안 페이로드가 있으면 반환한다(라우트 이탈 플러시용)
|
|
* @returns {Object|null} POST/PUT 본문 또는 null
|
|
*/
|
|
const takePendingAutosavePayload = () => {
|
|
if (!import.meta.client) {
|
|
return null
|
|
}
|
|
window.clearTimeout(draftPersistTimer)
|
|
draftPersistTimer = null
|
|
if (props.saving || props.autoSaving) {
|
|
return null
|
|
}
|
|
if (!shouldServerAutosaveDraft.value) {
|
|
return null
|
|
}
|
|
if (!hasUnsavedPostChanges.value) {
|
|
return null
|
|
}
|
|
if (!canPersistDraftPayload.value) {
|
|
return null
|
|
}
|
|
return createPostPayload()
|
|
}
|
|
|
|
watch(publishStatus, (next) => {
|
|
if (next !== 'published') {
|
|
publishTiming.value = 'now'
|
|
|
|
if (publishModalExpandedSection.value === 'timing') {
|
|
publishModalExpandedSection.value = null
|
|
}
|
|
}
|
|
})
|
|
|
|
watch(serializedPostFingerprint, () => {
|
|
if (!import.meta.client) {
|
|
return
|
|
}
|
|
if (props.saving || props.autoSaving) {
|
|
return
|
|
}
|
|
if (!shouldServerAutosaveDraft.value) {
|
|
return
|
|
}
|
|
if (!hasUnsavedPostChanges.value) {
|
|
return
|
|
}
|
|
if (!canPersistDraftPayload.value) {
|
|
return
|
|
}
|
|
window.clearTimeout(draftPersistTimer)
|
|
draftPersistTimer = window.setTimeout(() => {
|
|
if (props.saving || props.autoSaving) {
|
|
return
|
|
}
|
|
if (!shouldServerAutosaveDraft.value || !hasUnsavedPostChanges.value || !canPersistDraftPayload.value) {
|
|
return
|
|
}
|
|
emit('autosave', createPostPayload())
|
|
}, 1200)
|
|
})
|
|
|
|
onMounted(() => {
|
|
if (!props.initialPost?.id && !String(form.slug || '').trim()) {
|
|
const suffix = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
? crypto.randomUUID().replace(/-/g, '').slice(0, 24)
|
|
: `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 14)}`.slice(0, 24)
|
|
form.slug = `d${suffix}`
|
|
slugTouched.value = false
|
|
}
|
|
markSaved()
|
|
clearAutosaveLocal()
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
if (import.meta.client) {
|
|
window.clearTimeout(draftPersistTimer)
|
|
}
|
|
})
|
|
|
|
defineExpose({
|
|
clearAutosave: clearAutosaveLocal,
|
|
markSaved,
|
|
allowNextRouteLeave,
|
|
takePendingAutosavePayload
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<form class="admin-post-form flex h-screen min-h-screen overflow-hidden bg-white" @submit.prevent>
|
|
<div class="admin-post-form__workspace flex min-w-0 flex-1 flex-col bg-white">
|
|
<header class="admin-post-form__toolbar flex h-[56px] shrink-0 items-center bg-white px-8">
|
|
<div class="admin-post-form__toolbar-inner flex h-[34px] min-w-0 flex-1 items-center justify-between">
|
|
<div class="admin-post-form__toolbar-left flex h-full min-w-0 flex-1 items-center gap-3">
|
|
<NuxtLink class="admin-post-form__toolbar-link inline-flex shrink-0 items-center gap-2 rounded px-2 py-1.5 text-sm font-medium text-[#394047] transition-colors hover:bg-[#f1f3f4] hover:text-black" to="/admin/posts">
|
|
<span class="admin-post-form__toolbar-back text-lg leading-none" aria-hidden="true"><</span>
|
|
<span>Posts</span>
|
|
</NuxtLink>
|
|
<div class="admin-post-form__toolbar-status-row flex min-w-0 flex-1 items-center gap-2">
|
|
<NuxtLink
|
|
v-if="displayPublishedLive && canViewPost && publicUrl"
|
|
class="admin-post-form__toolbar-status-published inline-flex items-center gap-1 truncate rounded px-2 py-1.5 text-sm font-medium text-[#8E9CAC] transition-colors hover:bg-[#f1f3f4] hover:text-[#394047]"
|
|
:to="publicUrl"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
<span>Published</span>
|
|
<span aria-hidden="true">↗</span>
|
|
</NuxtLink>
|
|
<span
|
|
v-else-if="displayPublishedLive"
|
|
class="admin-post-form__toolbar-status-published-static inline-flex items-center gap-1 truncate rounded px-2 py-1.5 text-sm font-medium text-[#8E9CAC]"
|
|
>
|
|
<span>Published</span>
|
|
<span aria-hidden="true">↗</span>
|
|
</span>
|
|
<span
|
|
v-else-if="displayScheduled"
|
|
:title="scheduledStatusTooltip"
|
|
class="admin-post-form__toolbar-status-scheduled cursor-default truncate rounded px-2 py-1.5 text-sm font-normal text-[#2BBA3C]"
|
|
>
|
|
Scheduled
|
|
</span>
|
|
<span
|
|
v-else-if="headerDraftStatusText"
|
|
class="admin-post-form__toolbar-status-draft truncate rounded px-2 py-1.5 text-sm text-[#8E9CAC]"
|
|
>
|
|
{{ headerDraftStatusText }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="admin-post-form__toolbar-actions flex h-full shrink-0 items-center gap-2">
|
|
<template v-if="persistedPublishKind === 'draft'">
|
|
<template v-if="isDraftLike">
|
|
<button
|
|
class="admin-post-form__toolbar-publish rounded px-3 py-1.5 text-sm font-bold text-[#2BBA3C] transition-colors hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
@click="openPublishModal"
|
|
>
|
|
Publish
|
|
</button>
|
|
</template>
|
|
<button
|
|
v-else
|
|
class="admin-post-form__toolbar-update rounded px-3 py-1.5 text-sm font-bold transition-colors disabled:cursor-default disabled:text-[#8E9CAC] disabled:hover:bg-transparent enabled:text-[#394047] enabled:hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
:disabled="!hasUnsavedPostChanges || saving || autoSaving"
|
|
@click="requestToolbarUpdate"
|
|
>
|
|
Update
|
|
</button>
|
|
</template>
|
|
|
|
<template v-else-if="persistedPublishKind === 'publishedLive'">
|
|
<button
|
|
class="admin-post-form__toolbar-update rounded px-3 py-1.5 text-sm font-bold transition-colors disabled:cursor-default disabled:text-[#8E9CAC] disabled:hover:bg-transparent enabled:text-[#394047] enabled:hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
:disabled="!hasUnsavedPostChanges || saving || autoSaving"
|
|
@click="requestToolbarUpdate"
|
|
>
|
|
Update
|
|
</button>
|
|
<button
|
|
class="admin-post-form__toolbar-unpublish rounded px-3 py-1.5 text-sm font-semibold text-[#394047] transition-colors hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
:disabled="saving"
|
|
@click="openUnpublishModal"
|
|
>
|
|
Unpublish
|
|
</button>
|
|
</template>
|
|
|
|
<template v-else-if="persistedPublishKind === 'scheduled'">
|
|
<button
|
|
class="admin-post-form__toolbar-update rounded px-3 py-1.5 text-sm font-bold transition-colors disabled:cursor-default disabled:text-[#8E9CAC] disabled:hover:bg-transparent enabled:text-[#394047] enabled:hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
:disabled="!hasUnsavedPostChanges || saving || autoSaving"
|
|
@click="requestToolbarUpdate"
|
|
>
|
|
Update
|
|
</button>
|
|
<button
|
|
class="admin-post-form__toolbar-unschedule rounded px-3 py-1.5 text-sm font-semibold text-[#394047] transition-colors hover:bg-[#f1f3f4]"
|
|
type="button"
|
|
:disabled="saving"
|
|
@click="openUnpublishModal"
|
|
>
|
|
Unschedule
|
|
</button>
|
|
</template>
|
|
|
|
<button
|
|
class="admin-post-form__settings-toggle grid size-[34px] place-items-center rounded text-[#394047] transition-colors hover:bg-[#f1f3f4] hover:text-black"
|
|
type="button"
|
|
:aria-pressed="isSettingsOpen"
|
|
aria-label="게시물 설정 패널 전환"
|
|
@click="toggleSettingsPanel"
|
|
>
|
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M14 2.16699C14.3242 2.16699 14.4998 2.39365 14.5 2.57129V13.4287C14.5 13.606 14.3242 13.834 14 13.834H11.5V2.16699H14ZM2 2.16699H10.5V13.834H2C1.6756 13.834 1.5 13.6064 1.5 13.4287V2.57129C1.50024 2.39409 1.67607 2.16699 2 2.16699Z" stroke="currentColor" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<div
|
|
id="admin-post-form-editor-toolbar-host"
|
|
class="admin-post-form__editor-toolbar-host min-h-[40px] shrink-0 bg-white"
|
|
/>
|
|
|
|
<main class="admin-post-form__editor-scroll min-h-0 flex-1 overflow-y-auto">
|
|
<section class="admin-post-form__content mx-auto w-full max-w-[804px] px-8 pb-16 pt-16">
|
|
<div class="admin-post-form__feature-block mb-9">
|
|
<figure v-if="form.featuredImage" class="admin-post-form__featured-editor group relative overflow-hidden bg-white">
|
|
<img class="admin-post-form__featured-editor-image aspect-[16/9] w-full bg-surface object-cover" :src="form.featuredImage" alt="">
|
|
<figcaption class="admin-post-form__featured-editor-actions pointer-events-none absolute inset-0 flex items-end justify-end gap-2 bg-gradient-to-t from-black/40 via-black/5 to-transparent p-4 opacity-0 transition-opacity duration-150 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100">
|
|
<button class="admin-post-form__featured-change rounded bg-white/95 px-3 py-1.5 text-xs font-semibold text-[#15171a] shadow-sm transition-colors hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white" type="button" @click="openMediaPicker('featuredImage')">
|
|
변경
|
|
</button>
|
|
<button class="admin-post-form__featured-remove rounded bg-[#fff1f2]/95 px-3 py-1.5 text-xs font-semibold text-red-700 shadow-sm transition-colors hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white" type="button" @click="removeFeaturedImage">
|
|
삭제
|
|
</button>
|
|
</figcaption>
|
|
</figure>
|
|
<div v-else class="admin-post-form__feature-empty flex h-6 items-start">
|
|
<button class="admin-post-form__feature-add inline-flex items-center gap-1.5 rounded px-2 py-1 text-sm text-[#8e9cac] transition-colors hover:bg-[#eff1f2] hover:text-[#394047]" type="button" @click="openMediaPicker('featuredImage')">
|
|
<span aria-hidden="true">+</span>
|
|
<span>대표 이미지 추가</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<input
|
|
v-model="form.title"
|
|
class="admin-post-form__title-input mb-2 w-full border-0 bg-transparent px-0 py-0 text-3xl font-bold leading-tight text-ink outline-none placeholder:text-[#8e9cac]"
|
|
type="text"
|
|
placeholder="제목"
|
|
@keydown.enter="focusContentEditor"
|
|
@compositionstart="isTitleInputComposing = true"
|
|
@compositionend="isTitleInputComposing = false"
|
|
>
|
|
|
|
<div class="admin-post-form__field admin-post-form__content-editor text-sm">
|
|
<AdminMarkdownEditor ref="blockEditor" v-model="form.content" />
|
|
</div>
|
|
</section>
|
|
</main>
|
|
</div>
|
|
|
|
<aside
|
|
class="admin-post-form__settings flex h-screen shrink-0 flex-col overflow-hidden border-[#e3e6e8] bg-white transition-[width,border-color] duration-300 ease-out"
|
|
:class="isSettingsOpen ? 'w-[420px] border-l' : 'w-0 border-l-0'"
|
|
:aria-hidden="!isSettingsOpen"
|
|
>
|
|
<div class="admin-post-form__settings-inner flex h-full w-[420px] flex-col">
|
|
<div class="admin-post-form__settings-header flex h-[56px] shrink-0 items-center justify-between px-6">
|
|
<h2 class="admin-post-form__settings-title text-xl font-bold text-black">
|
|
게시물 설정
|
|
</h2>
|
|
<button class="admin-post-form__settings-close grid size-8 place-items-center rounded text-[#394047] transition-colors hover:bg-[#eff1f2] hover:text-black" type="button" aria-label="게시물 설정 닫기" @click="toggleSettingsPanel">
|
|
<span aria-hidden="true">x</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="admin-post-form__settings-body grid flex-1 content-start gap-4 overflow-y-auto px-6 pb-8 pt-8">
|
|
<div class="admin-post-form__field grid gap-1 text-sm">
|
|
<div class="admin-post-form__post-url-header flex h-[22px] items-center justify-between">
|
|
<span class="admin-post-form__label font-bold text-[#15171a]">Post URL</span>
|
|
<NuxtLink
|
|
v-if="canViewPost"
|
|
class="admin-post-form__view-post inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-[#8e9cac] transition-colors hover:bg-[#eff1f2] hover:text-[#394047]"
|
|
:to="publicUrl"
|
|
target="_blank"
|
|
>
|
|
<span>View Post</span>
|
|
<span aria-hidden="true">↗</span>
|
|
</NuxtLink>
|
|
</div>
|
|
<label class="admin-post-form__post-url-input flex h-[38px] items-center gap-2 rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-1 transition-colors hover:border-[#c8ced3] focus-within:border-[#8e9cac]">
|
|
<span class="admin-post-form__post-url-icon text-sm text-[#394047]" aria-hidden="true">⌘</span>
|
|
<input
|
|
v-model="form.slug"
|
|
class="admin-post-form__input min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-black outline-none"
|
|
type="text"
|
|
pattern="[a-z0-9가-힣]+(-[a-z0-9가-힣]+)*"
|
|
required
|
|
@input="touchSlug"
|
|
>
|
|
</label>
|
|
<p class="admin-post-form__post-url-hint text-xs text-[#7c8b9a]">
|
|
{{ postUrlHint }}
|
|
</p>
|
|
</div>
|
|
|
|
<label class="admin-post-form__field grid gap-2 text-sm">
|
|
<span class="admin-post-form__label font-medium">상태</span>
|
|
<select v-model="form.status" class="admin-post-form__select h-[38px] rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none">
|
|
<option value="draft">초안</option>
|
|
<option value="published">발행</option>
|
|
</select>
|
|
</label>
|
|
|
|
<div v-if="form.status === 'published'" class="admin-post-form__field grid gap-2 text-sm">
|
|
<span class="admin-post-form__label font-medium">발행 시각</span>
|
|
<div class="admin-post-form__publish-datetime-row grid grid-cols-2 gap-2">
|
|
<label class="admin-post-form__publish-date-field relative block">
|
|
<span class="sr-only">발행 날짜</span>
|
|
<input
|
|
v-model="settingsPublishDate"
|
|
class="admin-post-form__publish-date-input h-[38px] w-full rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 pr-9 text-sm text-[#15171a] transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none"
|
|
type="date"
|
|
>
|
|
<span class="admin-post-form__publish-date-icon pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[#8e9cac]" aria-hidden="true">
|
|
<svg class="size-4" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M8 2v3M16 2v3M3 9h18M5 5h14a2 2 0 012 2v13a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2z" stroke="currentColor" stroke-linecap="round" stroke-width="1.5" />
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
<label class="admin-post-form__publish-time-field relative block">
|
|
<span class="sr-only">발행 시각</span>
|
|
<input
|
|
v-model="settingsPublishTime"
|
|
class="admin-post-form__publish-time-input h-[38px] w-full rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 pr-12 text-sm text-[#15171a] transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none"
|
|
type="time"
|
|
>
|
|
<span class="admin-post-form__publish-time-zone pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium text-[#8e9cac]">KST</span>
|
|
</label>
|
|
</div>
|
|
<span class="admin-post-form__hint text-xs text-muted">
|
|
{{ isScheduledPost() ? '미래 시각이면 예약 발행으로 저장됩니다.' : '비워두면 저장 시점으로 발행됩니다.' }}
|
|
</span>
|
|
</div>
|
|
|
|
<label class="admin-post-form__field grid gap-2 text-sm">
|
|
<span class="admin-post-form__label font-medium">요약</span>
|
|
<textarea
|
|
v-model="form.excerpt"
|
|
class="admin-post-form__textarea min-h-[108px] rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none"
|
|
/>
|
|
</label>
|
|
|
|
<div class="admin-post-form__field grid gap-1 text-sm">
|
|
<span class="admin-post-form__label h-[22px] font-bold text-[#15171a]">Tags</span>
|
|
<label class="admin-post-form__tag-editor flex min-h-[38px] w-full items-center gap-2 rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-1 transition-colors hover:border-[#c8ced3] focus-within:border-[#8e9cac]">
|
|
<span
|
|
v-for="tag in selectedTags"
|
|
:key="tag"
|
|
class="admin-post-form__tag-badge inline-flex h-6 shrink-0 items-center gap-1.5 rounded-[3px] bg-[#ecd2de] px-2 text-sm text-[#e04e87]"
|
|
>
|
|
<span>{{ tag }}</span>
|
|
<button
|
|
class="admin-post-form__tag-remove inline-flex size-4 shrink-0 items-center justify-center rounded text-[#e04e87] transition-colors hover:bg-[#e7c3d2]"
|
|
type="button"
|
|
:aria-label="`${tag} 태그 삭제`"
|
|
@click="removeTag(tag)"
|
|
>
|
|
<svg class="size-2.5" version="1" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path fill="currentColor" d="M12.707 12L23.854.854a.5.5 0 00-.707-.707L12 11.293.854.146a.5.5 0 00-.707.707L11.293 12 .146 23.146a.5.5 0 00.708.708L12 12.707l11.146 11.146a.5.5 0 10.708-.706L12.707 12z" />
|
|
</svg>
|
|
</button>
|
|
</span>
|
|
<input
|
|
v-model="tagInput"
|
|
class="admin-post-form__tag-input min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-black outline-none placeholder:text-[#8e9cac]"
|
|
type="text"
|
|
placeholder="태그 입력"
|
|
@blur="addTagFromInput"
|
|
@keydown="handleTagKeydown"
|
|
@compositionstart="isTagInputComposing = true"
|
|
@compositionend="isTagInputComposing = false"
|
|
>
|
|
<span class="admin-post-form__tag-chevron text-xs text-[#394047]" aria-hidden="true">⌄</span>
|
|
</label>
|
|
</div>
|
|
|
|
<label class="admin-post-form__featured-toggle flex items-center justify-between gap-4 border-t border-[#e3e6e8] pt-5 text-sm">
|
|
<span class="admin-post-form__featured-toggle-copy flex min-w-0 items-center gap-3">
|
|
<span class="admin-post-form__featured-toggle-icon flex size-7 shrink-0 items-center justify-center text-[#15171a]" aria-hidden="true">
|
|
<svg class="size-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M12 3.5l2.7 5.47 6.04.88-4.37 4.26 1.03 6.01L12 17.28l-5.4 2.84 1.03-6.01-4.37-4.26 6.04-.88L12 3.5z" />
|
|
</svg>
|
|
</span>
|
|
<span class="admin-post-form__featured-toggle-label font-bold text-[#15171a]">
|
|
추천 글
|
|
</span>
|
|
</span>
|
|
<span class="admin-post-form__featured-toggle-control relative inline-flex h-7 w-12 shrink-0 items-center">
|
|
<input
|
|
v-model="form.isFeatured"
|
|
class="peer sr-only"
|
|
type="checkbox"
|
|
aria-label="추천 글로 표시"
|
|
>
|
|
<span class="absolute inset-0 rounded-full bg-[#c8ced3] transition-colors peer-checked:bg-[#15171a]" aria-hidden="true" />
|
|
<span class="relative ml-1 size-5 rounded-full bg-white shadow transition-transform peer-checked:translate-x-5" aria-hidden="true" />
|
|
</span>
|
|
</label>
|
|
|
|
<div class="admin-post-form__search-visibility grid gap-3 border-t border-[#e3e6e8] pt-5 text-sm">
|
|
<div>
|
|
<h2 class="admin-post-form__section-title text-sm font-semibold text-ink">
|
|
검색 노출
|
|
</h2>
|
|
<p class="admin-post-form__section-description mt-1 text-xs text-muted">
|
|
메타 제목·설명은 저장 시 글 제목과 요약을 그대로 사용합니다.
|
|
</p>
|
|
</div>
|
|
|
|
<label class="admin-post-form__checkbox flex items-start gap-2 text-sm">
|
|
<input
|
|
v-model="form.noindex"
|
|
class="admin-post-form__checkbox-input mt-1"
|
|
type="checkbox"
|
|
>
|
|
<span>
|
|
<span class="admin-post-form__label block font-medium">검색엔진 노출 제외</span>
|
|
<span class="admin-post-form__hint mt-1 block text-xs text-muted">공개 글이어도 robots noindex 메타를 추가합니다.</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div v-if="showDelete" class="admin-post-form__settings-bottom shrink-0 border-t border-[#e3e6e8] px-8 py-6">
|
|
<button
|
|
class="admin-post-form__delete-post flex h-10 w-full items-center justify-center gap-2 rounded border border-[#d7dde2] bg-white text-sm font-bold text-[#394047] transition-colors hover:border-[#d21a26] hover:bg-red-50 hover:text-[#d21a26] disabled:opacity-50"
|
|
type="button"
|
|
:disabled="deleting"
|
|
@click="deletePost"
|
|
>
|
|
<svg
|
|
class="admin-post-form__delete-post-icon size-5 shrink-0"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
aria-hidden="true"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path
|
|
d="M17.923 22.308H6.077a1.692 1.692 0 01-1.692-1.693V5.385h15.23v15.23a1.692 1.692 0 01-1.692 1.693zM9.462 17.23v-6.769M14.539 17.23v-6.769M1 5.385h22M14.539 2H9.462a1.692 1.692 0 00-1.693 1.692v1.693h8.462V3.692A1.692 1.692 0 0014.538 2z"
|
|
stroke="currentColor"
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="1.5"
|
|
/>
|
|
</svg>
|
|
<span>{{ deleting ? '삭제 중' : 'Delete post' }}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
|
|
<div
|
|
v-if="isMediaPickerOpen"
|
|
class="admin-post-form__media-picker fixed inset-0 z-50 grid place-items-center bg-black/40 px-5 py-8"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
@click.self="closeMediaPicker"
|
|
>
|
|
<section class="admin-post-form__media-picker-panel flex max-h-[86vh] min-h-[620px] w-full max-w-5xl flex-col overflow-hidden bg-white text-ink shadow-xl">
|
|
<div class="admin-post-form__media-picker-header flex items-center justify-between border-b border-line px-5 py-4">
|
|
<h2 class="admin-post-form__media-picker-title text-lg font-semibold">
|
|
대표 이미지
|
|
</h2>
|
|
<button class="admin-post-form__media-picker-close rounded border border-line px-3 py-1.5 text-sm font-semibold transition-colors hover:bg-[#eff1f2]" type="button" @click="closeMediaPicker">
|
|
닫기
|
|
</button>
|
|
</div>
|
|
<div class="admin-post-form__media-picker-tabs flex border-b border-line px-5">
|
|
<button
|
|
class="admin-post-form__media-picker-tab border-b-2 px-3 py-3 text-sm font-semibold transition-colors"
|
|
:class="activeMediaPickerTab === 'upload' ? 'border-[#15171a] text-[#15171a]' : 'border-transparent text-muted hover:text-[#15171a]'"
|
|
type="button"
|
|
@click="activeMediaPickerTab = 'upload'"
|
|
>
|
|
이미지 업로드
|
|
</button>
|
|
<button
|
|
class="admin-post-form__media-picker-tab border-b-2 px-3 py-3 text-sm font-semibold transition-colors"
|
|
:class="activeMediaPickerTab === 'library' ? 'border-[#15171a] text-[#15171a]' : 'border-transparent text-muted hover:text-[#15171a]'"
|
|
type="button"
|
|
@click="activeMediaPickerTab = 'library'"
|
|
>
|
|
미디어 라이브러리
|
|
</button>
|
|
</div>
|
|
<div class="admin-post-form__media-picker-body flex-1 overflow-y-auto p-5">
|
|
<div
|
|
v-if="activeMediaPickerTab === 'upload'"
|
|
class="admin-post-form__media-upload-zone grid min-h-[420px] place-items-center border border-dashed border-[#cfd5da] bg-white text-center"
|
|
@dragover.prevent
|
|
@drop.prevent="dropFeaturedImage"
|
|
>
|
|
<div class="admin-post-form__media-upload-inner grid gap-3">
|
|
<p class="admin-post-form__media-upload-title text-lg font-semibold text-[#15171a]">
|
|
파일을 끌어 업로드
|
|
</p>
|
|
<p class="admin-post-form__media-upload-or text-sm text-muted">
|
|
또는
|
|
</p>
|
|
<label class="admin-post-form__media-upload-button mx-auto inline-flex h-10 cursor-pointer items-center justify-center rounded border border-[#2b78d0] px-8 text-sm font-semibold text-[#1f6fbf] transition-colors hover:bg-blue-50">
|
|
{{ isUploadingFeaturedImage ? '업로드 중' : '파일 선택' }}
|
|
<input class="sr-only" type="file" accept="image/*" @change="uploadFeaturedImage">
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<template v-else>
|
|
<p v-if="isLoadingMedia" class="admin-post-form__media-picker-loading text-sm text-muted">
|
|
미디어를 불러오는 중입니다.
|
|
</p>
|
|
<div v-else-if="mediaItems.length" class="admin-post-form__media-picker-grid grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6">
|
|
<button
|
|
v-for="item in mediaItems"
|
|
:key="item.url"
|
|
class="admin-post-form__media-picker-item relative overflow-hidden border bg-white text-left transition hover:border-[#8e9cac] hover:shadow-sm"
|
|
:class="selectedMediaPickerUrl === item.url ? 'border-[#15171a] ring-2 ring-[#15171a]' : 'border-line'"
|
|
type="button"
|
|
:aria-pressed="selectedMediaPickerUrl === item.url"
|
|
@click="selectPickedImage(item)"
|
|
>
|
|
<img class="admin-post-form__media-picker-image aspect-square w-full bg-surface object-cover" :src="item.url" :alt="item.title">
|
|
<span class="admin-post-form__media-picker-name block truncate px-2 py-1.5 text-xs font-semibold text-ink">{{ item.name }}</span>
|
|
<span v-if="selectedMediaPickerUrl === item.url" class="admin-post-form__media-picker-selected absolute right-2 top-2 grid size-6 place-items-center rounded-full bg-[#15171a] text-white" aria-hidden="true">
|
|
<svg width="13" height="10" viewBox="0 0 13 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M1 5L4.5 8.5L12 1" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
</svg>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
<p v-else class="admin-post-form__media-picker-empty border border-dashed border-line p-8 text-center text-sm text-muted">
|
|
선택할 미디어가 없습니다.
|
|
</p>
|
|
</template>
|
|
</div>
|
|
<div class="admin-post-form__media-picker-footer flex h-14 shrink-0 items-center justify-end border-t border-line px-5">
|
|
<button
|
|
class="admin-post-form__media-picker-confirm h-9 rounded bg-[#15171a] px-4 text-sm font-semibold text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:bg-[#d7dce0] disabled:text-[#8e9cac]"
|
|
type="button"
|
|
:disabled="!selectedMediaPickerUrl"
|
|
@click="applyPickedImage"
|
|
>
|
|
대표 이미지로 적용
|
|
</button>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<AdminUnsavedChangesModal
|
|
:open="isUnsavedModalOpen"
|
|
@stay="stayOnUnsavedPage"
|
|
@leave="leaveUnsavedPage"
|
|
/>
|
|
|
|
<div
|
|
v-if="isPublishModalOpen"
|
|
class="admin-post-form__publish-modal fixed inset-0 z-[70] flex flex-col bg-white"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
aria-labelledby="admin-post-form-publish-modal-title"
|
|
>
|
|
<header class="admin-post-form__publish-modal-header absolute inset-x-0 top-0 z-10 flex h-14 shrink-0 items-center justify-between bg-white/95 px-6 backdrop-blur-sm supports-[backdrop-filter]:bg-white/80">
|
|
<h2 id="admin-post-form-publish-modal-title" class="text-[15px] font-semibold text-[#15171a]">
|
|
발행
|
|
</h2>
|
|
<button class="rounded px-3 py-1.5 text-[13px] font-semibold text-[#394047] hover:bg-[#eff1f2]" type="button" @click="closePublishModal">
|
|
닫기
|
|
</button>
|
|
</header>
|
|
|
|
<div class="flex min-h-0 flex-1 flex-col overflow-y-auto pt-14">
|
|
<div class="admin-post-form__publish-modal-body flex min-h-[calc(100dvh-3.5rem)] flex-1 flex-col items-center justify-center px-6 pb-16">
|
|
<div class="w-full max-w-[640px]">
|
|
<div class="admin-post-form__publish-modal-hero mb-10 sm:mb-12">
|
|
<p class="text-[clamp(28px,7vw,46px)] font-black text-[#2bba3c]">
|
|
준비됐어요, 발행하세요.
|
|
</p>
|
|
<p class="text-[clamp(28px,7vw,46px)] font-black leading-[0.95] text-[#15171a]">
|
|
세상과 공유해 보세요.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="admin-post-form__publish-settings w-full">
|
|
<div class="admin-post-form__publish-setting">
|
|
<button
|
|
class="admin-post-form__publish-setting-title flex w-full items-center gap-3 py-4 text-left text-[15px] font-semibold text-[#15171a] transition-colors"
|
|
type="button"
|
|
:aria-expanded="publishModalExpandedSection === 'status'"
|
|
aria-controls="admin-post-form-publish-status-panel"
|
|
data-test-setting="publish-type"
|
|
@click="togglePublishModalSection('status')"
|
|
>
|
|
<span class="flex size-6 shrink-0 items-center justify-center text-[#959eab]" aria-hidden="true">
|
|
<svg class="size-4" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M23 1L6.21 13.013v9.408L12 17.355" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" />
|
|
<path d="M1 9.105L23 1l-3.474 22L1 9.105z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" />
|
|
</svg>
|
|
</span>
|
|
<span class="min-w-0 flex-1">{{ publishStatusSummaryLabel }}</span>
|
|
<span class="flex size-2.5 shrink-0 items-center justify-center text-[#959eab]" aria-hidden="true">
|
|
<svg
|
|
class="size-[22px] transition-transform duration-200 ease-out"
|
|
:class="{ 'rotate-180': publishModalExpandedSection === 'status' }"
|
|
fill="currentColor"
|
|
viewBox="0 0 26 24"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path clip-rule="evenodd" d="M1.043 6.604a1 1 0 011.414 0L13 17.146 23.543 6.604a1 1 0 011.414 1.414l-10.72 10.719a1.75 1.75 0 01-2.474 0L1.042 8.018a1 1 0 010-1.414zm11.78 10.72v-.001zm.355 0v-.001z" fill-rule="evenodd" />
|
|
</svg>
|
|
</span>
|
|
</button>
|
|
<div
|
|
v-show="publishModalExpandedSection === 'status'"
|
|
id="admin-post-form-publish-status-panel"
|
|
class="admin-post-form__publish-setting-panel px-4 pb-4"
|
|
>
|
|
<div class="flex flex-wrap gap-2">
|
|
<button
|
|
class="rounded-full border px-3 py-1.5 text-[13px] font-semibold"
|
|
:class="publishStatus === 'published' ? 'border-[#15171a] bg-[#15171a] text-white' : 'border-[#d7dde2] bg-white text-[#394047]'"
|
|
type="button"
|
|
@click="selectPublishStatus('published')"
|
|
>
|
|
발행
|
|
</button>
|
|
<button
|
|
class="rounded-full border px-3 py-1.5 text-[13px] font-semibold"
|
|
:class="publishStatus === 'draft' ? 'border-[#15171a] bg-[#15171a] text-white' : 'border-[#d7dde2] bg-white text-[#394047]'"
|
|
type="button"
|
|
@click="selectPublishStatus('draft')"
|
|
>
|
|
초안
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="publishStatus === 'published'" class="admin-post-form__publish-setting admin-post-form__publish-setting--timing border-t border-[#e3e6e8]">
|
|
<button
|
|
class="admin-post-form__publish-setting-title flex w-full items-center gap-3 py-4 text-left text-[15px] font-semibold text-[#15171a] transition-colors"
|
|
type="button"
|
|
:aria-expanded="publishModalExpandedSection === 'timing'"
|
|
aria-controls="admin-post-form-publish-timing-panel"
|
|
data-test-setting="publish-at"
|
|
@click="togglePublishModalSection('timing')"
|
|
>
|
|
<span class="flex size-6 shrink-0 items-center justify-center text-[#959eab]" aria-hidden="true">
|
|
<svg class="size-4" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M12 23c6.075 0 11-4.925 11-11S18.075 1 12 1 1 5.925 1 12s4.925 11 11 11z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" />
|
|
<path d="M12 6v6h6" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" />
|
|
</svg>
|
|
</span>
|
|
<span class="min-w-0 flex-1">{{ publishTimingSummaryLabel }}</span>
|
|
<span class="flex size-2.5 shrink-0 items-center justify-center text-[#959eab]" aria-hidden="true">
|
|
<svg
|
|
class="size-[22px] transition-transform duration-200 ease-out"
|
|
:class="{ 'rotate-180': publishModalExpandedSection === 'timing' }"
|
|
fill="currentColor"
|
|
viewBox="0 0 26 24"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path clip-rule="evenodd" d="M1.043 6.604a1 1 0 011.414 0L13 17.146 23.543 6.604a1 1 0 011.414 1.414l-10.72 10.719a1.75 1.75 0 01-2.474 0L1.042 8.018a1 1 0 010-1.414zm11.78 10.72v-.001zm.355 0v-.001z" fill-rule="evenodd" />
|
|
</svg>
|
|
</span>
|
|
</button>
|
|
<div
|
|
v-show="publishModalExpandedSection === 'timing'"
|
|
id="admin-post-form-publish-timing-panel"
|
|
class="admin-post-form__publish-setting-panel px-4 pb-4"
|
|
>
|
|
<div class="flex flex-wrap gap-2">
|
|
<button
|
|
class="rounded-full border px-3 py-1.5 text-[13px] font-semibold"
|
|
:class="publishTiming === 'now' ? 'border-[#15171a] bg-[#15171a] text-white' : 'border-[#d7dde2] bg-white text-[#394047]'"
|
|
type="button"
|
|
@click="selectPublishTiming('now')"
|
|
>
|
|
지금 바로
|
|
</button>
|
|
<button
|
|
class="rounded-full border px-3 py-1.5 text-[13px] font-semibold"
|
|
:class="publishTiming === 'schedule' ? 'border-[#15171a] bg-[#15171a] text-white' : 'border-[#d7dde2] bg-white text-[#394047]'"
|
|
type="button"
|
|
@click="selectPublishTiming('schedule')"
|
|
>
|
|
예약
|
|
</button>
|
|
</div>
|
|
<div v-if="publishTiming === 'schedule'" class="admin-post-form__publish-schedule-datetime mt-3 grid max-w-[360px] grid-cols-2 gap-2">
|
|
<label class="admin-post-form__publish-date-field relative block">
|
|
<span class="sr-only">예약 발행 날짜</span>
|
|
<input
|
|
v-model="modalScheduleDate"
|
|
class="admin-post-form__publish-date-input h-[38px] w-full rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 pr-9 text-sm text-[#15171a] transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none"
|
|
type="date"
|
|
>
|
|
<span class="admin-post-form__publish-date-icon pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[#8e9cac]" aria-hidden="true">
|
|
<svg class="size-4" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M8 2v3M16 2v3M3 9h18M5 5h14a2 2 0 012 2v13a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2z" stroke="currentColor" stroke-linecap="round" stroke-width="1.5" />
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
<label class="admin-post-form__publish-time-field relative block">
|
|
<span class="sr-only">예약 발행 시각</span>
|
|
<input
|
|
v-model="modalScheduleTime"
|
|
class="admin-post-form__publish-time-input h-[38px] w-full rounded border border-[#e3e6e8] bg-[#eff1f2] px-3 py-2 pr-12 text-sm text-[#15171a] transition-colors hover:border-[#c8ced3] focus:border-[#8e9cac] focus:outline-none"
|
|
type="time"
|
|
>
|
|
<span class="admin-post-form__publish-time-zone pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium text-[#8e9cac]">KST</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-post-form__publish-modal-actions mt-10">
|
|
<button
|
|
class="rounded bg-[#15171a] px-5 py-2.5 text-[14px] font-semibold text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:bg-[#d7dce0] disabled:text-[#8e9cac]"
|
|
type="button"
|
|
:disabled="saving || autoSaving"
|
|
@click="submitFromPublishModal"
|
|
>
|
|
{{ saving || autoSaving ? '저장 중…' : '최종 확인하고 저장 →' }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
v-if="isUnpublishModalOpen"
|
|
class="admin-post-form__unpublish-modal fixed inset-0 z-[70] flex flex-col bg-white"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
aria-labelledby="admin-post-form-unpublish-modal-title"
|
|
>
|
|
<header class="admin-post-form__unpublish-modal-header absolute inset-x-0 top-0 z-10 flex h-14 shrink-0 items-center justify-between bg-white/95 px-6 backdrop-blur-sm supports-[backdrop-filter]:bg-white/80">
|
|
<h2 id="admin-post-form-unpublish-modal-title" class="text-[15px] font-semibold text-[#15171a]">
|
|
{{ unpublishModalKind === 'scheduled' ? '예약 취소' : '발행 취소' }}
|
|
</h2>
|
|
<button class="rounded border border-[#d7dde2] px-3 py-1.5 text-[13px] font-semibold text-[#394047] hover:bg-[#eff1f2]" type="button" @click="closeUnpublishModal">
|
|
닫기
|
|
</button>
|
|
</header>
|
|
|
|
<div class="flex min-h-0 flex-1 flex-col overflow-y-auto pt-14">
|
|
<div class="admin-post-form__unpublish-modal-body flex min-h-[calc(100dvh-3.5rem)] flex-1 flex-col items-center justify-center px-6 pb-16">
|
|
<div class="w-full max-w-[640px]">
|
|
<div class="admin-post-form__unpublish-modal-hero mb-6">
|
|
<p class="text-[clamp(28px,7vw,46px)] font-black leading-[1.05] text-[#15171a]">
|
|
<template v-if="unpublishModalKind === 'scheduled'">
|
|
이 글은 <span class="text-[#2bba3c]">예약</span>되어 있습니다
|
|
</template>
|
|
<template v-else>
|
|
이 글은 <span class="text-[#2bba3c]">발행</span>되었습니다
|
|
</template>
|
|
</p>
|
|
</div>
|
|
<p v-if="unpublishPersistedPublishedLabel" class="admin-post-form__unpublish-modal-summary mb-8 text-base text-[#394047]">
|
|
<template v-if="unpublishModalKind === 'scheduled'">
|
|
{{ unpublishPersistedPublishedLabel }}에 발행되도록 예약되어 있습니다.
|
|
</template>
|
|
<template v-else>
|
|
사이트에 {{ unpublishPersistedPublishedLabel }}에 발행되었습니다.
|
|
</template>
|
|
</p>
|
|
<button
|
|
class="admin-post-form__unpublish-confirm inline-flex items-center gap-1 text-base font-semibold text-[#2bba3c] transition-colors hover:text-[#229a32] disabled:opacity-50"
|
|
type="button"
|
|
:disabled="saving"
|
|
@click="confirmUnpublishOrUnschedule"
|
|
>
|
|
<span>{{ unpublishModalKind === 'scheduled' ? '예약 취소하고 초안으로 되돌리기' : '발행 취소하고 초안으로 되돌리기' }}</span>
|
|
<span aria-hidden="true">→</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</template>
|
|
|
|
<style scoped>
|
|
input[type='date']::-webkit-calendar-picker-indicator,
|
|
input[type='time']::-webkit-calendar-picker-indicator {
|
|
opacity: 0;
|
|
}
|
|
|
|
input[type='date'],
|
|
input[type='time'] {
|
|
-webkit-appearance: none;
|
|
appearance: none;
|
|
}
|
|
</style>
|