From e7eff0037cd723c236b47df1dd1fe062cd320735 Mon Sep 17 00:00:00 2001 From: "yuan.ji" <961999367@qq.com> Date: Fri, 8 May 2026 21:05:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(@vben/plugins):=20tiptap=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=96=B0=E5=A2=9E=20maxHeight=20=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 maxHeight prop 支持限制编辑器最大高度 - 编辑器内容区超出最大高度时自动滚动 - 移除 style.css 中未使用的 CSS 规则 --- packages/effects/plugins/src/tiptap/style.css | 6 ----- .../effects/plugins/src/tiptap/tiptap.vue | 13 +++++++++-- packages/effects/plugins/src/tiptap/types.ts | 1 + playground/src/adapter/component/index.ts | 23 ++++++++++++++++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/packages/effects/plugins/src/tiptap/style.css b/packages/effects/plugins/src/tiptap/style.css index 2d8052c1d..3f5f6cc8f 100644 --- a/packages/effects/plugins/src/tiptap/style.css +++ b/packages/effects/plugins/src/tiptap/style.css @@ -1,9 +1,5 @@ @reference "@vben/tailwind-config/theme"; -.vben-tiptap-content > * + * { - @apply mt-3; -} - .vben-tiptap-content h1 { @apply text-2xl font-bold leading-[1.4]; } @@ -50,8 +46,6 @@ .vben-tiptap-content img, .vben-tiptap-content .vben-tiptap__image { - @apply my-4 block h-auto rounded-2xl border border-border; - max-width: min(100%, 640px); } diff --git a/packages/effects/plugins/src/tiptap/tiptap.vue b/packages/effects/plugins/src/tiptap/tiptap.vue index 6dd99d3d8..2c4da366b 100644 --- a/packages/effects/plugins/src/tiptap/tiptap.vue +++ b/packages/effects/plugins/src/tiptap/tiptap.vue @@ -28,6 +28,7 @@ const props = withDefaults(defineProps(), { extensions: undefined, imageUpload: undefined, minHeight: 240, + maxHeight: 400, placeholder: $t('ui.tiptap.placeholder'), previewable: true, toolbar: true, @@ -41,9 +42,14 @@ const contentMinHeight = computed(() => ? `${props.minHeight}px` : props.minHeight, ); +const contentMaxHeight = computed(() => + typeof props.maxHeight === 'number' + ? `${props.maxHeight}px` + : props.maxHeight, +); const tiptapContentClass = cn( 'vben-tiptap-content vben-tiptap__content', - 'text-foreground min-h-(--vben-tiptap-min-height) leading-7 outline-none', + 'text-foreground max-h-(--vben-tiptap-max-height) min-h-(--vben-tiptap-min-height) overflow-auto leading-7 outline-none', ); const blobUrlTracker = new Set(); const editor = useEditor({ @@ -154,7 +160,10 @@ onBeforeUnmount(() => {