From eaaebeaebbd8617bd781089664ec9aa15aa50841 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 19 Jun 2015 22:39:41 +0200 Subject: [PATCH] refactoring paste --- AppKit/CPTextView/CPTextView.j | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index aa931481a..991b3b587 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -2239,25 +2239,15 @@ var _CPCopyPlaceholder = '-'; _CPNativeInputField.oncopy = function(e) { var pasteboard = [CPPasteboard generalPasteboard], - string, - currentFirstResponder = [[CPApp mainWindow] firstResponder]; - string = [[currentFirstResponder stringValue] substringWithRange:[currentFirstResponder selectedRange]]; - e.clipboardData.setData('text/plain', string); - [pasteboard declareTypes:[CPStringPboardType] owner:nil]; - [pasteboard setString:string forType:CPStringPboardType]; + string; + var currentFirstResponder = [[CPApp mainWindow] firstResponder]; - if ([currentFirstResponder isRichText] && [currentFirstResponder respondsToSelector:@selector(textStorage)]) - { - var stringForPasting = [[currentFirstResponder textStorage] attributedSubstringFromRange:CPMakeRangeCopy([currentFirstResponder selectedRange])]; + [currentFirstResponder copy:currentFirstResponder]; + // dataForPasting = [pasteboard dataForType:CPRichStringPboardType], + stringForPasting = [pasteboard stringForType:CPStringPboardType]; - if (stringForPasting._rangeEntries.length > 1) - { - var richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}]; - [pasteboard setString:richData forType:CPStringPboardType]; - e.clipboardData.setData('text/plain', richData); - // e.clipboardData.setData('application/rtf', richData); // does not seem to work (e.g. in Pages.app) - } - } + e.clipboardData.setData('text/plain', stringForPasting); + // e.clipboardData.setData('application/rtf', stringForPasting); // does not seem to work e.preventDefault(); e.stopPropagation();