feat: 커스텀 페이지 customContentReady 함수 추가
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// @ts-ignore
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
import type { DirectiveBinding } from 'vue'
|
||||
@@ -35,9 +36,12 @@ const commonTags = [
|
||||
'thead',
|
||||
'tbody',
|
||||
'tfoot',
|
||||
'video',
|
||||
'source',
|
||||
'tr',
|
||||
'th',
|
||||
'td',
|
||||
'section',
|
||||
] as const
|
||||
|
||||
// 공통 허용 속성
|
||||
@@ -55,16 +59,20 @@ const commonAttrs = [
|
||||
'colspan',
|
||||
'rowspan',
|
||||
'scope',
|
||||
'type',
|
||||
'autoplay',
|
||||
'muted',
|
||||
'loop',
|
||||
'playsinline',
|
||||
'controls',
|
||||
'preload',
|
||||
'poster',
|
||||
] as const
|
||||
|
||||
// 기본 설정 (일반 사용자용)
|
||||
const defaultConfig: DOMPurifyConfig = {
|
||||
ALLOWED_TAGS: [
|
||||
...commonTags
|
||||
],
|
||||
ALLOWED_ATTR: [
|
||||
...commonAttrs
|
||||
],
|
||||
ALLOWED_TAGS: [...commonTags],
|
||||
ALLOWED_ATTR: [...commonAttrs],
|
||||
}
|
||||
|
||||
// 관리자용 설정 (확장된 태그 및 속성)
|
||||
@@ -74,6 +82,7 @@ const adminConfig: DOMPurifyConfig = {
|
||||
'iframe',
|
||||
'link',
|
||||
'style',
|
||||
'script',
|
||||
'blockquote',
|
||||
],
|
||||
ALLOWED_ATTR: [
|
||||
@@ -133,16 +142,21 @@ function createDirectiveHandler(config: DOMPurifyConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
export default defineNuxtPlugin(nuxtApp => {
|
||||
// SSR 환경에서는 디렉티브 등록하지 않음
|
||||
// if (!import.meta.client) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// 기본 디렉티브: v-dompurify-html
|
||||
nuxtApp.vueApp.directive('dompurify-html', createDirectiveHandler(defaultConfig))
|
||||
nuxtApp.vueApp.directive(
|
||||
'dompurify-html',
|
||||
createDirectiveHandler(defaultConfig)
|
||||
)
|
||||
|
||||
// 관리자용 디렉티브: v-dompurify-admin
|
||||
nuxtApp.vueApp.directive('dompurify-admin', createDirectiveHandler(adminConfig))
|
||||
nuxtApp.vueApp.directive(
|
||||
'dompurify-admin',
|
||||
createDirectiveHandler(adminConfig)
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user