diff --git a/web/components/contract/contract-description.tsx b/web/components/contract/contract-description.tsx index 277d5de0..f9db0cd9 100644 --- a/web/components/contract/contract-description.tsx +++ b/web/components/contract/contract-description.tsx @@ -99,9 +99,6 @@ function RichEditContract(props: { contract: Contract; isAdmin?: boolean }) { .setContent(contract.description) .focus('end') .insertContent(`

${editTimestamp()}

`) - .insertContent( - `` - ) .run() }} > diff --git a/web/components/editor.tsx b/web/components/editor.tsx index a4ad758b..0dc87157 100644 --- a/web/components/editor.tsx +++ b/web/components/editor.tsx @@ -71,12 +71,20 @@ export function useTextEditor(props: { (file) => file.type.startsWith('image') ) - if (!imageFiles.length) { - return // if no files pasted, use default paste handler + if (imageFiles.length) { + event.preventDefault() + upload.mutate(imageFiles) } - event.preventDefault() - upload.mutate(imageFiles) + // If the pasted content is iframe code, directly inject it + const text = event.clipboardData?.getData('text/plain').trim() ?? '' + const isValidIframe = /^$/.test(text) + if (isValidIframe) { + editor.chain().insertContent(text).run() + return true // Prevent the code from getting pasted as text + } + + return // Otherwise, use default paste handler }, }, })