mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-08 15:26:39 +00:00
This commit is contained in:
parent
472b95516d
commit
51e0f8b107
@ -21,7 +21,10 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { EDITOR_OPTIONS } from '../../constants/BlockEditor.constants';
|
import {
|
||||||
|
EDITOR_OPTIONS,
|
||||||
|
TEXT_TYPES,
|
||||||
|
} from '../../constants/BlockEditor.constants';
|
||||||
import { formatContent, setEditorContent } from '../../utils/BlockEditorUtils';
|
import { formatContent, setEditorContent } from '../../utils/BlockEditorUtils';
|
||||||
import Banner from '../common/Banner/Banner';
|
import Banner from '../common/Banner/Banner';
|
||||||
import { useEntityAttachment } from '../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider';
|
import { useEntityAttachment } from '../common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider';
|
||||||
@ -79,12 +82,16 @@ const BlockEditor = forwardRef<BlockEditorRef, BlockEditorProps>(
|
|||||||
},
|
},
|
||||||
handleDOMEvents: {
|
handleDOMEvents: {
|
||||||
paste: (view, event) => {
|
paste: (view, event) => {
|
||||||
// Allow paste if either image or file upload is enabled
|
const items = Array.from(event.clipboardData?.items || []);
|
||||||
if (!allowImageUpload && !allowFileUpload) {
|
// Check if the paste contains text types
|
||||||
|
const hasText = items.some(
|
||||||
|
(item) => item.kind === 'string' && TEXT_TYPES.includes(item.type)
|
||||||
|
);
|
||||||
|
// Allow paste if either image or file upload is enabled or if the paste contains text types
|
||||||
|
if ((!allowImageUpload && !allowFileUpload) || hasText) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = Array.from(event.clipboardData?.items || []);
|
|
||||||
const files = items
|
const files = items
|
||||||
.filter((item) => item.kind === FileType.FILE)
|
.filter((item) => item.kind === FileType.FILE)
|
||||||
.map((item) => item.getAsFile())
|
.map((item) => item.getAsFile())
|
||||||
|
@ -73,3 +73,5 @@ export const LINK_PASTE_REGEX =
|
|||||||
/(?:^|\s)\[([^\]]*)?\]\((\S+)(?: ["“](.+)["”])?\)/gi;
|
/(?:^|\s)\[([^\]]*)?\]\((\S+)(?: ["“](.+)["”])?\)/gi;
|
||||||
|
|
||||||
export const UPLOADED_ASSETS_URL = '/api/v1/attachments/';
|
export const UPLOADED_ASSETS_URL = '/api/v1/attachments/';
|
||||||
|
|
||||||
|
export const TEXT_TYPES = ['text/plain', 'text/rtf'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user