ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.59k stars 335 forks source link

handlePaste does not work with SHIFT+INSERT #1384

Closed BertschMario closed 1 year ago

BertschMario commented 1 year ago
handlePaste: (view, event, slice) => {
        const fileUrls: string[] = [];
        slice.content.descendants((node) => node.type.name === 'image' && !fileUrls.push(node.attrs['src']));
        if (fileUrls.length === 0) return false;
        return true;
      },

The handlePaste event does only trigger on CTRL+V and Rightclick=>Paste, but SHIFT+INSERT does not trigger the event correctly.

marijnh commented 1 year ago

Which browser and OS is this on? It works fine on Chrome and Firefox Linux.

BertschMario commented 1 year ago

Which browser and OS is this on? It works fine on Chrome and Firefox Linux.

Ohh, my mistake, I just saw that the event is being triggered, but no image is being inserted and therefore it can't be read. The insertion with SHIFT+INSERT doesn't work in the example either: https://prosemirror.net/examples/basic/ Tested on Ubuntu 22.04 => Chrome/Firefox & Windows => Chrome/Firefox

marijnh commented 1 year ago

It was doing a plain text parse because shift was being held, which I guess isn't appropriate for shift-insert. Attached patch should fix this.