diff --git a/src/common/common.js b/src/common/common.js index 9acd369..a93e8a8 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -81,6 +81,34 @@ const common = { return true; }, + + /** + * 에디터에 내용이 있는지 확인 + * + * @param { Quill } content + * @returns true: 값 없음, false: 값 있음 + */ + isNotValidContent(content) { + if (!content.value?.ops?.length) return true; + + // 이미지 포함 여부 확인 + const hasImage = content.value.ops.some(op => op.insert && typeof op.insert === 'object' && op.insert.image); + // 텍스트 포함 여부 확인 + const hasText = content.value.ops.some(op => typeof op.insert === 'string' && op.insert.trim().length > 0); + + // 텍스트 또는 이미지가 하나라도 있으면 유효한 내용 + return !(hasText || hasImage); + }, + + /** + * 빈 값 확인 + * + * @param {ref} text ex) inNotValidInput(data.value); + * @returns + */ + isNotValidInput(text) { + return text.trim().length === 0; + }, }; export default { diff --git a/src/components/category/CategoryBtn.vue b/src/components/category/CategoryBtn.vue index 9e8138e..491374f 100644 --- a/src/components/category/CategoryBtn.vue +++ b/src/components/category/CategoryBtn.vue @@ -31,7 +31,7 @@ -