mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(database): format AI field text output as rich text AI fields with text output can store rich text, reusing the rich long text editor without mentions or images. New AI fields default to it in the create form; existing fields, API clients and old imports stay plain. Rich fields add a one-line formatting instruction to the prompt. Also: - forward row-modal edits of AI fields, which were never saved - keep image markdown as literal text when images are off, instead of reducing it to its alt text and losing the URL on save - escape user file image references as `![alt]\[name]` so a reference nested in another's alt text can't stay live - return 400 instead of 500 when a PATCH would make a primary field rich text Closes #6220 * fix: preserve reference image URLs in rich text Defined Markdown image tokens carry their destination and title separately from the raw reference marker. Keep that data as self-contained literal inline text when image nodes are disabled, and align the preview behavior. Add parser, AI row persistence, and browser regressions while preserving internal file references and the existing inline-image path. * fix: handle AI field changes during generation
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import { flushPromises } from '@vue/test-utils'
|
|
|
|
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import FieldRichTextModal from '@baserow/modules/database/components/view/FieldRichTextModal'
|
|
import RichTextEditor from '@baserow/modules/core/components/editor/RichTextEditor'
|
|
|
|
describe('FieldRichTextModal', () => {
|
|
let testApp
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await testApp.afterEach()
|
|
})
|
|
|
|
test('appends the editor menu to the body, not inside the modal', async () => {
|
|
const wrapper = await testApp.mount(FieldRichTextModal, {
|
|
props: {
|
|
field: { id: 1, name: 'Notes' },
|
|
modelValue: 'Hello',
|
|
},
|
|
})
|
|
|
|
wrapper.vm.toggle()
|
|
await flushPromises()
|
|
await new Promise((resolve) => setTimeout(resolve))
|
|
|
|
const modal = wrapper.vm.getTeleportedElement()
|
|
const floatingMenu = document.querySelector(
|
|
'.rich-text-editor__floating-menu'
|
|
)
|
|
|
|
expect(floatingMenu).not.toBeNull()
|
|
// Body-level, not inside the positioned modal, so floating-ui positions it correctly.
|
|
expect(document.body.contains(floatingMenu)).toBe(true)
|
|
expect(modal.contains(floatingMenu)).toBe(false)
|
|
})
|
|
|
|
test.each([true, false])(
|
|
'passes enableImages=%s to its editor',
|
|
async (enableImages) => {
|
|
const wrapper = await testApp.mount(FieldRichTextModal, {
|
|
props: {
|
|
field: { id: 1, name: 'Notes' },
|
|
modelValue: 'Hello',
|
|
enableImages,
|
|
},
|
|
})
|
|
|
|
wrapper.vm.toggle()
|
|
await flushPromises()
|
|
|
|
expect(wrapper.findComponent(RichTextEditor).props('enableImages')).toBe(
|
|
enableImages
|
|
)
|
|
}
|
|
)
|
|
})
|