diff --git a/src/components/richtext/rich-edit.vue b/src/components/richtext/rich-edit.vue index 5d02ae1..6f07353 100644 --- a/src/components/richtext/rich-edit.vue +++ b/src/components/richtext/rich-edit.vue @@ -2,7 +2,7 @@
+ mode="default" @onCreated="handleCreated" @onChange="change" @customPaste="customPaste" />
@@ -73,10 +73,22 @@ const handleCreated = (editor) => { valueHtml.value = props.modelValue } +const customPaste = (editor, event, callback) => { + let htmlData = event.clipboardData.getData('text/html') // 获取粘贴的 html + htmlData = htmlData.replace(' props.modelValue, () => { valueHtml.value = props.modelValue }) - +const isEmpty = () => { + return editorRef.value.isEmpty() +} - +defineExpose({ isEmpty }) + + diff --git a/src/view/content/components/articleEdit.vue b/src/view/content/components/articleEdit.vue index e50a285..bf1c6c4 100644 --- a/src/view/content/components/articleEdit.vue +++ b/src/view/content/components/articleEdit.vue @@ -57,7 +57,8 @@
- +
@@ -140,7 +141,6 @@ import { getChannelTree } from '@/api/channel' import { getTagList } from '@/api/tag' import ChooseImg from '@/components/chooseImg/index.vue' import UploadCommon from '@/components/upload/common.vue' -import UploadImage from '@/components/upload/image.vue' import { addArticle, updateArticle, @@ -149,7 +149,6 @@ import { import { importFetcherArticleById } from '@/api/fetcher' import { isUrl } from '@/utils/validator' import { articleTypeOptions } from '@/utils/options' -import { formatDate } from '@/utils/format' // 组件定义 defineOptions({ @@ -166,10 +165,10 @@ const fullscreenLoading = ref(true) const isEdit = ref(false) // 确定是修改还是增加 isEdit = true 为修改,否则为增加 const fetcherArticleId = ref(0) // 记录从抓取库导入的文章id const elEditFormRef = ref() +const contentEditorRef = ref(null) const checkContent = (rule, value, callback) => { - const content = value.replace(/<\/?.+?\/?>|\r|\n|\s*/g, '') - if (content === '') { + if (contentEditorRef.value.isEmpty()) { callback(new Error(rule.message)) } else { callback()