mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-25 16:05:52 +00:00
refactor rich copy: to CPTextView
This commit is contained in:
1 parent
78b2c4d094
commit
dd187aef08
2 files changed
+14
-15
No files matched your search
@@ -35,7 +35,6 @@
|
||||
@global CPStringPboardType
|
||||
@class CPAttributedString
|
||||
@class _CPRTFParser
|
||||
@class _CPRTFProducer
|
||||
|
||||
@protocol CPTextDelegate <CPObject>
|
||||
|
||||
@@ -156,19 +155,6 @@ CPKernAttributeName = @"CPKernAttributeName";
|
||||
// put plain representation on the pasteboad unconditionally
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:[[self stringValue] substringWithRange:selectedRange] forType:CPStringPboardType];
|
||||
|
||||
if ([self isRichText] && [self respondsToSelector:@selector(textStorage)])
|
||||
{
|
||||
var stringForPasting = [[self textStorage] attributedSubstringFromRange:CPMakeRangeCopy(selectedRange)];
|
||||
|
||||
// put rich representation on the pasteboad only if we have multliple attributes selected
|
||||
if (stringForPasting._rangeEntries.length > 1)
|
||||
{
|
||||
var richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}];
|
||||
// [pasteboard declareTypes:[CPStringPboardType, CPRichStringPboardType] owner:nil]; // this does currently do not work due to limitations in cappuccino
|
||||
[pasteboard setString:richData forType:CPStringPboardType]; // crude hack to make rich pasting possible in chrome and firefox. simply put rtf on the plain pasteboard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (id)_stringForPasting
|
||||
|
||||
@@ -259,13 +259,26 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Copy and past methods
|
||||
#pragma mark Copy and paste methods
|
||||
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
[_CPNativeInputManager setLastCopyWasNative:[sender isKindOfClass:[_CPNativeInputManager class]]];
|
||||
_copySelectionGranularity = _previousSelectionGranularity;
|
||||
[super copy:sender];
|
||||
|
||||
if ([self isRichText])
|
||||
{
|
||||
var stringForPasting = [_textStorage attributedSubstringFromRange:CPMakeRangeCopy(selectedRange)];
|
||||
|
||||
// put rich representation on the pasteboad only if we have multliple attributes selected
|
||||
if (stringForPasting._rangeEntries.length > 1)
|
||||
{
|
||||
var richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}];
|
||||
// [pasteboard declareTypes:[CPStringPboardType, CPRichStringPboardType] owner:nil]; // this does currently do not work due to limitations in cappuccino
|
||||
[pasteboard setString:richData forType:CPStringPboardType]; // crude hack to make rich pasting possible in chrome and firefox: put rtf on the plain pasteboard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)paste:(id)sender
|
||||
|
||||
Reference in new issue
Block a user