From ea67bec9d9e2caa8dd2cab21209b092e0fb9dc99 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 24 Nov 2015 15:23:29 -0800 Subject: [PATCH] fix(paste): avoid code duplication, just give menu items roles Manual implementation of clipboard behaviors was not necessary and meant that pasting images via right-click didn't go through the same code path as Cmd-V. May fix #228, depending on the exact issue. --- .../contenteditable/contenteditable.cjsx | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/components/contenteditable/contenteditable.cjsx b/src/components/contenteditable/contenteditable.cjsx index a139b8e1c..17d0f5541 100644 --- a/src/components/contenteditable/contenteditable.cjsx +++ b/src/components/contenteditable/contenteditable.cjsx @@ -611,31 +611,15 @@ class Contenteditable extends React.Component @refs["toolbarController"]?.forceClose() event.preventDefault() - selection = document.getSelection() - range = DOMUtils.Mutating.getRangeAtAndSelectWord(selection, 0) - text = range.toString() - remote = require('remote') - clipboard = require('clipboard') Menu = remote.require('menu') MenuItem = remote.require('menu-item') - cut = => - clipboard.writeText(text) - DOMUtils.Mutating.applyTextInRange(range, selection, '') - - copy = => - clipboard.writeText(text) - - paste = => - DOMUtils.Mutating.applyTextInRange(range, selection, clipboard.readText()) - menu = new Menu() - @_runPluginHandlersForEvent("onShowContextMenu", event, menu) - menu.append(new MenuItem({ label: 'Cut', click: cut})) - menu.append(new MenuItem({ label: 'Copy', click: copy})) - menu.append(new MenuItem({ label: 'Paste', click: paste})) + menu.append(new MenuItem({ label: 'Cut', role: 'cut'})) + menu.append(new MenuItem({ label: 'Copy', role: 'copy'})) + menu.append(new MenuItem({ label: 'Paste', role: 'paste'})) menu.popup(remote.getCurrentWindow()) _onMouseDown: (event) =>