Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/web-pkg/src/editor/composables/useEditorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import EmojiPickerModal from '../../components/Modals/EmojiPickerModal.vue'
import { arrayBufferToDataUrl, withoutExtension } from '../../helpers'
import { TextEditorState } from '../types'
import { requestLinkPanel, printEditorContent } from '../helpers'
import { supportedImageMimeTypes } from '../extensions/imageFileHandler'
import TextEditorSearchAndReplacePanel from '../components/TextEditorSearchAndReplacePanel.vue'
import TextEditorTableSizeSelector from '../components/TextEditorTableSizeSelector.vue'

Expand Down Expand Up @@ -690,7 +691,7 @@ export function useEditorActions(state: TextEditorState) {
customComponent: markRaw(FilePickerModal),
hideActions: true,
customComponentAttrs: () => ({
allowedFileTypes: ['image/png', 'image/gif', 'image/jpeg', 'image/svg'],
allowedFileTypes: supportedImageMimeTypes,
parentFolderLink: getParentFolderLink(resource),
callbackFn: async ({ resource }: { resource: Resource }) => {
if (!resource.mimeType?.startsWith('image/')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-pkg/src/editor/extensions/imageFileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FileHandler from '@tiptap/extension-file-handler'
import type { Editor, Extension } from '@tiptap/core'

// Explicit list instead of `image/*`, because the file handler matches mime types exactly
const supportedImageMimeTypes = [
export const supportedImageMimeTypes = [
'image/apng',
'image/avif',
'image/bmp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,18 @@ describe('useEditorActions', () => {
})
})

describe('imageCloud', () => {
it('allows picking all image types the editor supports', () => {
actions.imageCloud().toolbarAction!(createMockEditor(), 'image-cloud')
const { dispatchModal } = useModals()
const { customComponentAttrs } = vi.mocked(dispatchModal).mock.calls[0][0]

expect(customComponentAttrs().allowedFileTypes).toEqual(
expect.arrayContaining(['image/svg+xml', 'image/webp'])
)
})
})

describe('imageUrl', () => {
it('toolbarAction dispatches a modal with input', () => {
const editor = createMockEditor()
Expand Down
Loading