From d4b2b02c54175746ab96eda7e0c83a9574b7fca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=9E=E5=8F=AF=20=C2=B7=20YU=20KE?= <1798456934@qq.com> Date: Tue, 1 Sep 2026 13:45:25 +0800 Subject: [PATCH] fix(form): bind rich editor through modelValue (#8347) --- .changeset/fresh-tiptap-model.md | 6 ++++ apps/web-antdv-next/src/adapter/form.test.ts | 33 ++++++++++++++++++++ apps/web-antdv-next/src/adapter/form.ts | 2 ++ playground/src/adapter/form.ts | 2 ++ 4 files changed, 43 insertions(+) create mode 100644 .changeset/fresh-tiptap-model.md create mode 100644 apps/web-antdv-next/src/adapter/form.test.ts diff --git a/.changeset/fresh-tiptap-model.md b/.changeset/fresh-tiptap-model.md new file mode 100644 index 000000000..9de9acd18 --- /dev/null +++ b/.changeset/fresh-tiptap-model.md @@ -0,0 +1,6 @@ +--- +'@vben/web-antdv-next': patch +'@vben/playground': patch +--- + +fix: bind VbenTiptap through the standard Vue model protocol diff --git a/apps/web-antdv-next/src/adapter/form.test.ts b/apps/web-antdv-next/src/adapter/form.test.ts new file mode 100644 index 000000000..ee51238d0 --- /dev/null +++ b/apps/web-antdv-next/src/adapter/form.test.ts @@ -0,0 +1,33 @@ +import { describe, expect, it, vi } from 'vitest'; + +import { initSetupVbenForm } from './form'; + +const mocks = vi.hoisted(() => ({ + setupVbenForm: vi.fn(), +})); + +vi.mock('@vben/common-ui', () => ({ + setupVbenForm: mocks.setupVbenForm, + useVbenForm: vi.fn(), + z: {}, +})); + +vi.mock('@vben/locales', () => ({ + $t: (key: string) => key, +})); + +describe('antdv-next form adapter', () => { + it('keeps VbenTiptap on the standard Vue model protocol', async () => { + await initSetupVbenForm(); + + expect(mocks.setupVbenForm).toHaveBeenCalledWith( + expect.objectContaining({ + config: expect.objectContaining({ + modelPropNameMap: expect.objectContaining({ + RichEditor: 'modelValue', + }), + }), + }), + ); + }); +}); diff --git a/apps/web-antdv-next/src/adapter/form.ts b/apps/web-antdv-next/src/adapter/form.ts index 9bbfd5c1e..b999e6797 100644 --- a/apps/web-antdv-next/src/adapter/form.ts +++ b/apps/web-antdv-next/src/adapter/form.ts @@ -19,6 +19,8 @@ async function initSetupVbenForm() { modelPropNameMap: { Checkbox: 'checked', Radio: 'checked', + // VbenTiptap uses Vue's standard modelValue/update:modelValue pair. + RichEditor: 'modelValue', Switch: 'checked', Upload: 'fileList', }, diff --git a/playground/src/adapter/form.ts b/playground/src/adapter/form.ts index fa692c246..64da5b533 100644 --- a/playground/src/adapter/form.ts +++ b/playground/src/adapter/form.ts @@ -18,6 +18,8 @@ async function initSetupVbenForm() { modelPropNameMap: { Checkbox: 'checked', Radio: 'checked', + // VbenTiptap uses Vue's standard modelValue/update:modelValue pair. + RichEditor: 'modelValue', Switch: 'checked', Upload: 'fileList', },