diff --git a/AppKit/CPTextView/CPLayoutManager.j b/AppKit/CPTextView/CPLayoutManager.j index 48f1ec470..cb4f7f0ca 100644 --- a/AppKit/CPTextView/CPLayoutManager.j +++ b/AppKit/CPTextView/CPLayoutManager.j @@ -1027,9 +1027,10 @@ var _sortRange = function(location, anObject) return CPOrderedAscending; } +// fixme: filter for a textContainer var _objectWithLocationInRange = function(aList, aLocation) { - var index = [aList _indexOfObject: aLocation sortedByFunction:_sortRange context:nil]; + var index = [aList _indexOfObject:aLocation sortedByFunction:_sortRange context:nil]; if (index != CPNotFound) return aList[index]; diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 62b3326af..0c6802a5e 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -224,8 +224,7 @@ var kDelegateRespondsTo_textShouldBeginEditing - (void)paste:(id)sender { var e = [CPApp currentEvent]._DOMEvent; - - if (e.currentTarget == document) // this is somehow necessary to prevent double pasting + if (e && e.currentTarget == document) // this is somehow necessary to prevent double pasting return; var stringForPasting = [self _stringForPasting]; @@ -2210,6 +2209,57 @@ var _CPCopyPlaceholder = '-'; return false; }, true); // capture mode + if (CPBrowserIsEngine(CPGeckoBrowserEngine)) + { + _CPNativeInputField.onpaste = function(e) + { + var pasteboard = [CPPasteboard generalPasteboard]; + [pasteboard declareTypes:[CPStringPboardType] owner:nil]; + + var data = e.clipboardData.getData('text/plain'); + [pasteboard setString:data forType:CPStringPboardType]; + + var currentFirstResponder = [[CPApp mainWindow] firstResponder]; + + setTimeout(function(){ // prevent dom-flickering + [currentFirstResponder paste:self]; + }, 20); + return false; + } + _CPNativeInputField.oncopy = function(e) + { + var pasteboard = [CPPasteboard generalPasteboard], + string, + currentFirstResponder = [[CPApp mainWindow] firstResponder]; + + [currentFirstResponder copy:self]; + // dataForPasting = [pasteboard dataForType:CPRichStringPboardType], + stringForPasting = [pasteboard stringForType:CPStringPboardType]; + e.clipboardData.setData('text/plain', stringForPasting); + // e.clipboardData.setData('application/rtf', stringForPasting); // does not seem to work + return false; + + } + _CPNativeInputField.oncut = function(e) + { + + var pasteboard = [CPPasteboard generalPasteboard], + string, + currentFirstResponder = [[CPApp mainWindow] firstResponder]; + + setTimeout(function(){ // prevent dom-flickering + [currentFirstResponder cut:self]; + }, 20); + + [currentFirstResponder copy:self]; // this is necessary because cut will only execute in the future + // dataForPasting = [pasteboard dataForType:CPRichStringPboardType], + stringForPasting = [pasteboard stringForType:CPStringPboardType]; + + e.clipboardData.setData('text/plain', stringForPasting); + // e.clipboardData.setData('application/rtf', stringForPasting); // does not seem to work + return false; + } + } } + (void)focus