fix(components): fix clipboard data null checks in TipTap.vue

- Add proper null check for clipboardData.items before accessing length
- Replace for...of loop with indexed for loop to avoid iterator issue with DataTransferItemList
This commit is contained in:
kolaente 2025-11-22 16:22:36 +01:00
parent 278eae387c
commit eab1a211ae
1 changed files with 5 additions and 4 deletions

View File

@ -355,11 +355,12 @@ const PasteHandler = Extension.create({
key: new PluginKey('pasteHandler'),
props: {
handlePaste: (view, event) => {
// Handle images pasted from clipboard
if (typeof props.uploadCallback !== 'undefined' && event.clipboardData?.items?.length > 0) {
for (const item of event.clipboardData.items) {
// Handle images pasted from clipboard
if (typeof props.uploadCallback !== 'undefined' && event.clipboardData?.items && event.clipboardData.items.length > 0) {
for (let i = 0; i < event.clipboardData.items.length; i++) {
const item = event.clipboardData.items[i]
if (item.kind === 'file' && item.type.startsWith('image/')) {
const file = item.getAsFile()
if (file) {