copy/paste: fix pasting not working from Edit menu

pull/3623/head
Mime Čuvalo 2024-04-26 14:44:32 +01:00
rodzic a319ad9497
commit d7a8e7999b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: BA84499022AC984D
1 zmienionych plików z 8 dodań i 9 usunięć

Wyświetl plik

@ -74,13 +74,12 @@ const INPUTS = ['input', 'select', 'textarea']
* @param editor - The editor instance.
* @internal
*/
function disallowClipboardEvents(editor: Editor) {
function disallowClipboardEvents() {
const { activeElement } = document
return (
editor.getIsMenuOpen() ||
(activeElement &&
(activeElement.getAttribute('contenteditable') ||
INPUTS.indexOf(activeElement.tagName.toLowerCase()) > -1))
activeElement &&
(activeElement.getAttribute('contenteditable') ||
INPUTS.indexOf(activeElement.tagName.toLowerCase()) > -1)
)
}
@ -584,7 +583,7 @@ export function useMenuClipboardEvents() {
// If we're editing a shape, or we are focusing an editable input, then
// we would want the user's paste interaction to go to that element or
// input instead; e.g. when pasting text into a text shape's content
if (editor.getEditingShapeId() !== null || disallowClipboardEvents(editor)) return
if (editor.getEditingShapeId() !== null || disallowClipboardEvents()) return
if (Array.isArray(data) && data[0] instanceof ClipboardItem) {
handlePasteFromClipboardApi(editor, data, point)
@ -621,7 +620,7 @@ export function useNativeClipboardEvents() {
if (
editor.getSelectedShapeIds().length === 0 ||
editor.getEditingShapeId() !== null ||
disallowClipboardEvents(editor)
disallowClipboardEvents()
) {
return
}
@ -635,7 +634,7 @@ export function useNativeClipboardEvents() {
if (
editor.getSelectedShapeIds().length === 0 ||
editor.getEditingShapeId() !== null ||
disallowClipboardEvents(editor)
disallowClipboardEvents()
) {
return
}
@ -664,7 +663,7 @@ export function useNativeClipboardEvents() {
// If we're editing a shape, or we are focusing an editable input, then
// we would want the user's paste interaction to go to that element or
// input instead; e.g. when pasting text into a text shape's content
if (editor.getEditingShapeId() !== null || disallowClipboardEvents(editor)) return
if (editor.getEditingShapeId() !== null || disallowClipboardEvents()) return
// First try to use the clipboard data on the event
if (e.clipboardData && !editor.inputs.shiftKey) {