This repository was archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathSLKTextView+SLKAdditions.h
131 lines (97 loc) · 3.71 KB
/
SLKTextView+SLKAdditions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
// SlackTextViewController
// https://github.com/slackhq/SlackTextViewController
//
// Copyright 2014-2016 Slack Technologies, Inc.
// Licence: MIT-Licence
//
#import "SLKTextView.h"
NS_ASSUME_NONNULL_BEGIN
/** @name SLKTextView additional features used for SlackTextViewController. */
@interface SLKTextView (SLKAdditions)
/**
Clears the text.
@param clearUndo YES if clearing the text should also clear the undo manager (if enabled).
*/
- (void)slk_clearText:(BOOL)clearUndo;
/**
Scrolls to the very end of the content size, animated.
@param animated YES if the scrolling should be animated.
*/
- (void)slk_scrollToBottomAnimated:(BOOL)animated;
/**
Scrolls to the caret position, animated.
@param animated YES if the scrolling should be animated.
*/
- (void)slk_scrollToCaretPositonAnimated:(BOOL)animated;
/**
Inserts a line break at the caret's position.
*/
- (void)slk_insertNewLineBreak;
/**
Inserts a string at the caret's position.
@param text The string to be appended to the current text.
*/
- (void)slk_insertTextAtCaretRange:(NSString *)text;
/**
Insert a string at the caret's position with stylization from the attributes.
@param text The string to be appended to the current text.
@param attributes The attributes used to stylize the text.
*/
- (void)slk_insertTextAtCaretRange:(NSString *)text
withAttributes:(NSDictionary<NSString *, id> *)attributes;
/**
Adds a string to a specific range.
@param text The string to be appended to the current text.
@param range The range where to insert text.
@return The range of the newly inserted text.
*/
- (NSRange)slk_insertText:(NSString *)text inRange:(NSRange)range;
/**
Adds a string to a specific range, with stylization from the attributes.
@param text The string to be appended to the current text.
@param attributes The attributes used to stylize the text.
@param range The range where to insert text.
@return The range of the newly inserted text.
*/
- (NSRange)slk_insertText:(NSString *)text
withAttributes:(NSDictionary<NSString *, id> *)attributes
inRange:(NSRange)range;
/**
Sets the text attributes for the attributed string in the provided range.
@param attributes The attributes used to style NSAttributedString class.
@param range The range of the text that needs to be stylized by the given attributes.
@return An attributed string.
*/
- (NSAttributedString *)slk_setAttributes:(NSDictionary<NSString *, id> *)attributes
inRange:(NSRange)range;
/**
Inserts an attributed string at the caret's position.
@param attributedText The attributed string to be appended.
*/
- (void)slk_insertAttributedTextAtCaretRange:(NSAttributedString *)attributedText;
/**
Adds an attributed string to a specific range.
@param text The string to be appended to the current text.
@param range The range where to insert text.
@return The range of the newly inserted text.
*/
- (NSRange)slk_insertAttributedText:(NSAttributedString *)attributedText inRange:(NSRange)range;
/**
Removes all attributed string attributes from the text view, for the given range.
@param range The range to remove the attributes.
*/
- (void)slk_clearAllAttributesInRange:(NSRange)range;
/**
Returns a default attributed string, using the text view's font and text color.
@param text The string to be used for creating a new attributed string.
@return An attributed string.
*/
- (NSAttributedString *)slk_defaultAttributedStringForText:(NSString *)text;
/**
Registers the current text for future undo actions.
@param description A simple description associated with the Undo or Redo command.
*/
- (void)slk_prepareForUndo:(NSString *)description;
@end
NS_ASSUME_NONNULL_END