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:
parent
278eae387c
commit
eab1a211ae
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue