Browse Source

fix(form): bind rich editor through modelValue (#8347)

pull/8351/head
俞可 · YU KE 4 weeks ago
committed by GitHub
parent
commit
d4b2b02c54
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      .changeset/fresh-tiptap-model.md
  2. 33
      apps/web-antdv-next/src/adapter/form.test.ts
  3. 2
      apps/web-antdv-next/src/adapter/form.ts
  4. 2
      playground/src/adapter/form.ts

6
.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

33
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',
}),
}),
}),
);
});
});

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

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

Loading…
Cancel
Save