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', },