react-native-enriched 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -9
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerDelegate.java +1 -1
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedTextInputViewManagerInterface.java +1 -1
- package/android/generated/jni/react/renderer/components/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +19 -2
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +3 -3
- package/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewPackage.kt +2 -0
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedCodeBlockSpan.kt +36 -1
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedImageSpan.kt +132 -11
- package/android/src/main/java/com/swmansion/enriched/spans/EnrichedSpans.kt +4 -0
- package/android/src/main/java/com/swmansion/enriched/spans/utils/ForceRedrawSpan.kt +13 -0
- package/android/src/main/java/com/swmansion/enriched/styles/HtmlStyle.kt +2 -9
- package/android/src/main/java/com/swmansion/enriched/styles/InlineStyles.kt +1 -0
- package/android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt +110 -3
- package/android/src/main/java/com/swmansion/enriched/styles/ParametrizedStyles.kt +57 -30
- package/android/src/main/java/com/swmansion/enriched/utils/AsyncDrawable.kt +91 -0
- package/android/src/main/java/com/swmansion/enriched/utils/EnrichedParser.java +16 -13
- package/android/src/main/java/com/swmansion/enriched/utils/ResourceManager.kt +26 -0
- package/android/src/main/java/com/swmansion/enriched/watchers/EnrichedSpanWatcher.kt +3 -0
- package/android/src/main/res/drawable/broken_image.xml +10 -0
- package/ios/EnrichedTextInputView.h +3 -0
- package/ios/EnrichedTextInputView.mm +97 -29
- package/ios/config/InputConfig.h +6 -0
- package/ios/config/InputConfig.mm +32 -0
- package/ios/generated/RNEnrichedTextInputViewSpec/Props.h +0 -45
- package/ios/generated/RNEnrichedTextInputViewSpec/RCTComponentViewHelpers.h +20 -4
- package/ios/inputParser/InputParser.mm +147 -24
- package/ios/internals/EnrichedTextInputViewShadowNode.h +1 -0
- package/ios/internals/EnrichedTextInputViewShadowNode.mm +29 -17
- package/ios/styles/BlockQuoteStyle.mm +5 -26
- package/ios/styles/BoldStyle.mm +2 -0
- package/ios/styles/CodeBlockStyle.mm +228 -0
- package/ios/styles/H1Style.mm +1 -0
- package/ios/styles/H2Style.mm +1 -0
- package/ios/styles/H3Style.mm +1 -0
- package/ios/styles/ImageStyle.mm +158 -0
- package/ios/styles/InlineCodeStyle.mm +2 -0
- package/ios/styles/ItalicStyle.mm +2 -0
- package/ios/styles/LinkStyle.mm +8 -0
- package/ios/styles/MentionStyle.mm +133 -36
- package/ios/styles/OrderedListStyle.mm +2 -0
- package/ios/styles/StrikethroughStyle.mm +2 -0
- package/ios/styles/UnderlineStyle.mm +2 -0
- package/ios/styles/UnorderedListStyle.mm +2 -0
- package/ios/utils/BaseStyleProtocol.h +1 -0
- package/ios/utils/ImageData.h +10 -0
- package/ios/utils/ImageData.mm +4 -0
- package/ios/utils/LayoutManagerExtension.mm +118 -3
- package/ios/utils/OccurenceUtils.h +4 -0
- package/ios/utils/OccurenceUtils.mm +47 -0
- package/ios/utils/ParagraphAttributesUtils.h +1 -0
- package/ios/utils/ParagraphAttributesUtils.mm +87 -20
- package/ios/utils/StyleHeaders.h +12 -0
- package/ios/utils/ZeroWidthSpaceUtils.mm +22 -10
- package/lib/module/EnrichedTextInput.js +2 -2
- package/lib/module/EnrichedTextInput.js.map +1 -1
- package/lib/module/EnrichedTextInputNativeComponent.ts +6 -5
- package/lib/module/normalizeHtmlStyle.js +0 -4
- package/lib/module/normalizeHtmlStyle.js.map +1 -1
- package/lib/typescript/src/EnrichedTextInput.d.ts +1 -5
- package/lib/typescript/src/EnrichedTextInput.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts +1 -5
- package/lib/typescript/src/EnrichedTextInputNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/normalizeHtmlStyle.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedTextInput.tsx +3 -7
- package/src/EnrichedTextInputNativeComponent.ts +6 -5
- package/src/normalizeHtmlStyle.ts +0 -4
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "EnrichedTextInputView.h"
|
|
4
4
|
#import "StyleHeaders.h"
|
|
5
5
|
#import "ParagraphsUtils.h"
|
|
6
|
+
#import "ColorExtension.h"
|
|
6
7
|
|
|
7
8
|
@implementation NSLayoutManager (LayoutManagerExtension)
|
|
8
9
|
|
|
@@ -52,11 +53,122 @@ static void const *kInputKey = &kInputKey;
|
|
|
52
53
|
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)self.input;
|
|
53
54
|
if(typedInput == nullptr) { return; }
|
|
54
55
|
|
|
56
|
+
NSRange inputRange = NSMakeRange(0, typedInput->textView.textStorage.length);
|
|
57
|
+
|
|
58
|
+
[self drawBlockQuotes:typedInput origin:origin inputRange:inputRange];
|
|
59
|
+
[self drawLists:typedInput origin:origin inputRange:inputRange];
|
|
60
|
+
[self drawCodeBlocks:typedInput origin:origin inputRange:inputRange];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)drawCodeBlocks:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin inputRange:(NSRange)inputRange
|
|
64
|
+
{
|
|
65
|
+
CodeBlockStyle *codeBlockStyle = typedInput->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
66
|
+
if(codeBlockStyle == nullptr) { return; }
|
|
67
|
+
|
|
68
|
+
NSArray<StylePair *> *allCodeBlocks = [codeBlockStyle findAllOccurences:inputRange];
|
|
69
|
+
NSArray<StylePair *> *mergedCodeBlocks = [self mergeContiguousStylePairs:allCodeBlocks];
|
|
70
|
+
UIColor *bgColor = [[typedInput->config codeBlockBgColor] colorWithAlphaIfNotTransparent:0.4];
|
|
71
|
+
CGFloat radius = [typedInput->config codeBlockBorderRadius];
|
|
72
|
+
[bgColor setFill];
|
|
73
|
+
|
|
74
|
+
for (StylePair *pair in mergedCodeBlocks) {
|
|
75
|
+
NSRange blockCharacterRange = [pair.rangeValue rangeValue];
|
|
76
|
+
if (blockCharacterRange.length == 0) continue;
|
|
77
|
+
|
|
78
|
+
NSArray *paragraphs = [ParagraphsUtils getSeparateParagraphsRangesIn:typedInput->textView range:blockCharacterRange];
|
|
79
|
+
if (paragraphs.count == 0) continue;
|
|
80
|
+
|
|
81
|
+
NSRange firstParagraphRange = [((NSValue *)[paragraphs firstObject]) rangeValue];
|
|
82
|
+
NSRange lastParagraphRange = [((NSValue *)[paragraphs lastObject]) rangeValue];
|
|
83
|
+
|
|
84
|
+
for (NSValue *paragraphValue in paragraphs) {
|
|
85
|
+
NSRange paragraphCharacterRange = [paragraphValue rangeValue];
|
|
86
|
+
|
|
87
|
+
BOOL isFirstParagraph = NSEqualRanges(paragraphCharacterRange, firstParagraphRange);
|
|
88
|
+
BOOL isLastParagraph = NSEqualRanges(paragraphCharacterRange, lastParagraphRange);
|
|
89
|
+
|
|
90
|
+
NSRange paragraphGlyphRange = [self glyphRangeForCharacterRange:paragraphCharacterRange actualCharacterRange:NULL];
|
|
91
|
+
|
|
92
|
+
__block BOOL isFirstLineOfParagraph = YES;
|
|
93
|
+
|
|
94
|
+
[self enumerateLineFragmentsForGlyphRange:paragraphGlyphRange
|
|
95
|
+
usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer * _Nonnull textContainer, NSRange glyphRange, BOOL * _Nonnull stop) {
|
|
96
|
+
|
|
97
|
+
CGRect lineBgRect = rect;
|
|
98
|
+
lineBgRect.origin.x = origin.x;
|
|
99
|
+
lineBgRect.origin.y += origin.y;
|
|
100
|
+
lineBgRect.size.width = textContainer.size.width;
|
|
101
|
+
|
|
102
|
+
UIRectCorner cornersForThisLine = 0;
|
|
103
|
+
|
|
104
|
+
if (isFirstParagraph && isFirstLineOfParagraph) {
|
|
105
|
+
cornersForThisLine = UIRectCornerTopLeft | UIRectCornerTopRight;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
BOOL isLastLineOfParagraph = (NSMaxRange(glyphRange) >= NSMaxRange(paragraphGlyphRange));
|
|
109
|
+
|
|
110
|
+
if (isLastParagraph && isLastLineOfParagraph) {
|
|
111
|
+
cornersForThisLine = cornersForThisLine | UIRectCornerBottomLeft | UIRectCornerBottomRight;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:lineBgRect
|
|
115
|
+
byRoundingCorners:cornersForThisLine
|
|
116
|
+
cornerRadii:CGSizeMake(radius, radius)];
|
|
117
|
+
[path fill];
|
|
118
|
+
|
|
119
|
+
isFirstLineOfParagraph = NO;
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (NSArray<StylePair *> *)mergeContiguousStylePairs:(NSArray<StylePair *> *)pairs
|
|
126
|
+
{
|
|
127
|
+
if (pairs.count == 0) {
|
|
128
|
+
return @[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
NSMutableArray<StylePair *> *mergedPairs = [[NSMutableArray alloc] init];
|
|
132
|
+
StylePair *currentPair = pairs[0];
|
|
133
|
+
NSRange currentRange = [currentPair.rangeValue rangeValue];
|
|
134
|
+
for (NSUInteger i = 1; i < pairs.count; i++) {
|
|
135
|
+
StylePair *nextPair = pairs[i];
|
|
136
|
+
NSRange nextRange = [nextPair.rangeValue rangeValue];
|
|
137
|
+
|
|
138
|
+
// The Gap Check:
|
|
139
|
+
// NSMaxRange(currentRange) is where the current block ends.
|
|
140
|
+
// nextRange.location is where the next block starts.
|
|
141
|
+
if (NSMaxRange(currentRange) == nextRange.location) {
|
|
142
|
+
// They touch perfectly (no gap). Merge them.
|
|
143
|
+
currentRange.length += nextRange.length;
|
|
144
|
+
} else {
|
|
145
|
+
// There is a gap (indices don't match).
|
|
146
|
+
// 1. Save the finished block.
|
|
147
|
+
StylePair *mergedPair = [[StylePair alloc] init];
|
|
148
|
+
mergedPair.rangeValue = [NSValue valueWithRange:currentRange];
|
|
149
|
+
mergedPair.styleValue = currentPair.styleValue;
|
|
150
|
+
[mergedPairs addObject:mergedPair];
|
|
151
|
+
|
|
152
|
+
// 2. Start a brand new block.
|
|
153
|
+
currentPair = nextPair;
|
|
154
|
+
currentRange = nextRange;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Add the final block
|
|
159
|
+
StylePair *lastPair = [[StylePair alloc] init];
|
|
160
|
+
lastPair.rangeValue = [NSValue valueWithRange:currentRange];
|
|
161
|
+
lastPair.styleValue = currentPair.styleValue;
|
|
162
|
+
[mergedPairs addObject:lastPair];
|
|
163
|
+
|
|
164
|
+
return mergedPairs;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
- (void)drawBlockQuotes:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin inputRange:(NSRange)inputRange
|
|
168
|
+
{
|
|
55
169
|
BlockQuoteStyle *bqStyle = typedInput->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
56
170
|
if(bqStyle == nullptr) { return; }
|
|
57
171
|
|
|
58
|
-
NSRange inputRange = NSMakeRange(0, typedInput->textView.textStorage.length);
|
|
59
|
-
|
|
60
172
|
// it isn't the most performant but we have to check for all the blockquotes each time and redraw them
|
|
61
173
|
NSArray *allBlockquotes = [bqStyle findAllOccurences:inputRange];
|
|
62
174
|
|
|
@@ -78,7 +190,10 @@ static void const *kInputKey = &kInputKey;
|
|
|
78
190
|
}
|
|
79
191
|
];
|
|
80
192
|
}
|
|
81
|
-
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
- (void)drawLists:(EnrichedTextInputView *)typedInput origin:(CGPoint)origin inputRange:(NSRange)inputRange
|
|
196
|
+
{
|
|
82
197
|
UnorderedListStyle *ulStyle = typedInput->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
83
198
|
OrderedListStyle *olStyle = typedInput->stylesDict[@([OrderedListStyle getStyleType])];
|
|
84
199
|
if(ulStyle == nullptr || olStyle == nullptr) { return; }
|
|
@@ -40,4 +40,8 @@
|
|
|
40
40
|
withInput:(EnrichedTextInputView* _Nonnull)input
|
|
41
41
|
inRange:(NSRange)range
|
|
42
42
|
withCondition:(BOOL (NS_NOESCAPE ^_Nonnull)(id _Nullable value, NSRange range))condition;
|
|
43
|
+
+ (NSArray *_Nonnull)getRangesWithout
|
|
44
|
+
:(NSArray<NSNumber *> *_Nonnull)types
|
|
45
|
+
withInput:(EnrichedTextInputView* _Nonnull)input
|
|
46
|
+
inRange:(NSRange)range;
|
|
43
47
|
@end
|
|
@@ -152,4 +152,51 @@
|
|
|
152
152
|
return occurences;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
+ (NSArray *_Nonnull)getRangesWithout
|
|
156
|
+
:(NSArray<NSNumber *> *_Nonnull)types
|
|
157
|
+
withInput:(EnrichedTextInputView* _Nonnull)input
|
|
158
|
+
inRange:(NSRange)range
|
|
159
|
+
{
|
|
160
|
+
NSMutableArray<id> *activeStyleObjects = [[NSMutableArray alloc] init];
|
|
161
|
+
for(NSNumber *type in types) {
|
|
162
|
+
id<BaseStyleProtocol> styleClass = input->stylesDict[type];
|
|
163
|
+
[activeStyleObjects addObject:styleClass];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (activeStyleObjects.count == 0) {
|
|
167
|
+
return @[[NSValue valueWithRange:range]];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
NSMutableArray<NSValue *> *newRanges = [[NSMutableArray alloc] init];
|
|
171
|
+
NSUInteger lastRangeLocation = range.location;
|
|
172
|
+
NSUInteger endLocation = range.location + range.length;
|
|
173
|
+
|
|
174
|
+
for (NSUInteger i = range.location; i < endLocation; i++) {
|
|
175
|
+
NSRange currentRange = NSMakeRange(i, 1);
|
|
176
|
+
BOOL forbiddenStyleFound = NO;
|
|
177
|
+
|
|
178
|
+
for (id style in activeStyleObjects) {
|
|
179
|
+
if ([style detectStyle:currentRange]) {
|
|
180
|
+
forbiddenStyleFound = YES;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (forbiddenStyleFound) {
|
|
186
|
+
if (i > lastRangeLocation) {
|
|
187
|
+
NSRange cleanRange = NSMakeRange(lastRangeLocation, i - lastRangeLocation);
|
|
188
|
+
[newRanges addObject:[NSValue valueWithRange:cleanRange]];
|
|
189
|
+
}
|
|
190
|
+
lastRangeLocation = i + 1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (lastRangeLocation < endLocation) {
|
|
195
|
+
NSRange remainingRange = NSMakeRange(lastRangeLocation, endLocation - lastRangeLocation);
|
|
196
|
+
[newRanges addObject:[NSValue valueWithRange:remainingRange]];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return newRanges;
|
|
200
|
+
}
|
|
201
|
+
|
|
155
202
|
@end
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
// if the user backspaces the last character in a line, the iOS applies typing attributes from the previous line
|
|
10
10
|
// in the case of some paragraph styles it works especially bad when a list point just appears
|
|
11
|
-
//
|
|
11
|
+
// this method handles that case differently with or without present paragraph styles
|
|
12
12
|
+ (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text input:(id)input {
|
|
13
13
|
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)input;
|
|
14
14
|
UnorderedListStyle *ulStyle = typedInput->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
15
15
|
OrderedListStyle *olStyle = typedInput->stylesDict[@([OrderedListStyle getStyleType])];
|
|
16
16
|
BlockQuoteStyle *bqStyle = typedInput->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
17
|
+
CodeBlockStyle *cbStyle = typedInput->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
17
18
|
|
|
18
19
|
if(typedInput == nullptr) {
|
|
19
20
|
return NO;
|
|
@@ -34,29 +35,25 @@
|
|
|
34
35
|
|
|
35
36
|
NSRange nonNewlineRange = [(NSValue *)paragraphs.firstObject rangeValue];
|
|
36
37
|
|
|
37
|
-
//
|
|
38
|
+
// the backspace removes the whole content of a paragraph (possibly more but has to start where the paragraph starts)
|
|
38
39
|
if(range.location == nonNewlineRange.location && range.length >= nonNewlineRange.length) {
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[TextInsertionUtils replaceText:text at:range additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
53
|
-
[bqStyle addAttributes:NSMakeRange(range.location, 0)];
|
|
54
|
-
return YES;
|
|
40
|
+
|
|
41
|
+
// for lists, quotes and codeblocks present we do the following:
|
|
42
|
+
// - manually do the removing
|
|
43
|
+
// - reset typing attribtues so that the previous line styles don't get applied
|
|
44
|
+
// - reapply the paragraph style that was present so that a zero width space appears here
|
|
45
|
+
NSArray *handledStyles = @[ulStyle, olStyle, bqStyle, cbStyle];
|
|
46
|
+
for(id<BaseStyleProtocol> style in handledStyles) {
|
|
47
|
+
if([style detectStyle:nonNewlineRange]) {
|
|
48
|
+
[TextInsertionUtils replaceText:text at:range additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
49
|
+
typedInput->textView.typingAttributes = typedInput->defaultTypingAttributes;
|
|
50
|
+
[style addAttributes:NSMakeRange(range.location, 0)];
|
|
51
|
+
return YES;
|
|
52
|
+
}
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
// do the replacement manually
|
|
55
|
+
// otherwise (no paragraph styles present), we just do the replacement manually and reset typing attribtues
|
|
58
56
|
[TextInsertionUtils replaceText:text at:range additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
59
|
-
// reset typing attribtues
|
|
60
57
|
typedInput->textView.typingAttributes = typedInput->defaultTypingAttributes;
|
|
61
58
|
return YES;
|
|
62
59
|
}
|
|
@@ -64,4 +61,74 @@
|
|
|
64
61
|
return NO;
|
|
65
62
|
}
|
|
66
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Handles the specific case of backspacing a newline character, which results in merging two paragraphs.
|
|
66
|
+
*
|
|
67
|
+
* THE PROBLEM:
|
|
68
|
+
* When merging a bottom paragraph (Source) into a top paragraph (Destination), the bottom paragraph
|
|
69
|
+
* normally brings all its attributes with it. If the top paragraph is a restrictive style (like a CodeBlock),
|
|
70
|
+
* and the bottom paragraph contains a conflicting style (like an H1 Header), a standard merge would
|
|
71
|
+
* create an invalid state (e.g., a CodeBlock that is also a Header).
|
|
72
|
+
*
|
|
73
|
+
* THE SOLUTION:
|
|
74
|
+
* 1. Identifies the dominant style of the paragraph ABOVE the deleted newline (`leftParagraphStyle`).
|
|
75
|
+
* 2. Checks the paragraph BELOW the newline (`rightRange`) for any styles that conflict with or are blocked by the top style.
|
|
76
|
+
* 3. Explicitly removes those forbidden styles from the bottom paragraph *before* the merge occurs.
|
|
77
|
+
* 4. Performs the merge (deletes the newline).
|
|
78
|
+
*
|
|
79
|
+
* @return YES if the newline backspace was handled and sanitized; NO otherwise.
|
|
80
|
+
*/
|
|
81
|
+
+ (BOOL)handleNewlineBackspaceInRange:(NSRange)range replacementText:(NSString *)text input:(id)input {
|
|
82
|
+
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)input;
|
|
83
|
+
if(typedInput == nullptr) {
|
|
84
|
+
return NO;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if(text.length == 0 && range.length == 1 &&
|
|
88
|
+
[[NSCharacterSet newlineCharacterSet] characterIsMember:[typedInput->textView.textStorage.string characterAtIndex:range.location]]) {
|
|
89
|
+
NSRange leftRange = [typedInput->textView.textStorage.string paragraphRangeForRange:range];
|
|
90
|
+
|
|
91
|
+
id<BaseStyleProtocol> leftParagraphStyle = nullptr;
|
|
92
|
+
for (NSNumber *key in typedInput->stylesDict) {
|
|
93
|
+
id<BaseStyleProtocol> style = typedInput->stylesDict[key];
|
|
94
|
+
if([[style class] isParagraphStyle] && [style detectStyle:leftRange]) {
|
|
95
|
+
leftParagraphStyle = style;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if(leftParagraphStyle == nullptr) {
|
|
100
|
+
return NO;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// index out of bounds
|
|
104
|
+
if(range.location + 1 >= typedInput->textView.textStorage.string.length) {
|
|
105
|
+
return NO;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
NSRange rightRange = [typedInput->textView.textStorage.string paragraphRangeForRange:NSMakeRange(range.location + 1, 1)];
|
|
109
|
+
|
|
110
|
+
StyleType type = [[leftParagraphStyle class] getStyleType];
|
|
111
|
+
|
|
112
|
+
NSArray *conflictingStyles = [typedInput getPresentStyleTypesFrom:typedInput->conflictingStyles[@(type)] range:rightRange];
|
|
113
|
+
NSArray *blockingStyles = [typedInput getPresentStyleTypesFrom:typedInput->blockingStyles[@(type)] range:rightRange];
|
|
114
|
+
NSArray *allToBeRemoved = [conflictingStyles arrayByAddingObjectsFromArray:blockingStyles];
|
|
115
|
+
|
|
116
|
+
for(NSNumber *style in allToBeRemoved) {
|
|
117
|
+
id<BaseStyleProtocol> styleClass = typedInput->stylesDict[style];
|
|
118
|
+
|
|
119
|
+
// for ranges, we need to remove each occurence
|
|
120
|
+
NSArray<StylePair *> *allOccurences = [styleClass findAllOccurences:rightRange];
|
|
121
|
+
|
|
122
|
+
for(StylePair* pair in allOccurences) {
|
|
123
|
+
[styleClass removeAttributes: [pair.rangeValue rangeValue]];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
[TextInsertionUtils replaceText:text at:range additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
128
|
+
return YES;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return NO;
|
|
132
|
+
}
|
|
133
|
+
|
|
67
134
|
@end
|
package/ios/utils/StyleHeaders.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import "BaseStyleProtocol.h"
|
|
3
3
|
#import "LinkData.h"
|
|
4
4
|
#import "MentionParams.h"
|
|
5
|
+
#import "ImageData.h"
|
|
5
6
|
|
|
6
7
|
@interface BoldStyle : NSObject <BaseStyleProtocol>
|
|
7
8
|
@end
|
|
@@ -74,3 +75,14 @@
|
|
|
74
75
|
- (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
|
|
75
76
|
- (void)manageBlockquoteColor;
|
|
76
77
|
@end
|
|
78
|
+
|
|
79
|
+
@interface CodeBlockStyle : NSObject<BaseStyleProtocol>
|
|
80
|
+
- (void)manageCodeBlockFontAndColor;
|
|
81
|
+
- (BOOL)handleBackspaceInRange:(NSRange)range replacementText:(NSString *)text;
|
|
82
|
+
@end
|
|
83
|
+
|
|
84
|
+
@interface ImageStyle : NSObject<BaseStyleProtocol>
|
|
85
|
+
- (void)addImage:(NSString *)uri width:(CGFloat)width height:(CGFloat)height;
|
|
86
|
+
- (void)addImageAtRange:(NSRange)range imageData:(ImageData *)imageData withSelection:(BOOL)withSelection;
|
|
87
|
+
- (ImageData *)getImageDataAt:(NSUInteger)location;
|
|
88
|
+
@end
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
UnorderedListStyle *ulStyle = input->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
43
43
|
OrderedListStyle *olStyle = input->stylesDict[@([OrderedListStyle getStyleType])];
|
|
44
44
|
BlockQuoteStyle *bqStyle = input->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
45
|
+
CodeBlockStyle *cbStyle = input->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
45
46
|
|
|
46
|
-
// zero width spaces with no lists/
|
|
47
|
-
if(![ulStyle detectStyle:characterRange] && ![olStyle detectStyle:characterRange] && ![bqStyle detectStyle:characterRange]) {
|
|
47
|
+
// zero width spaces with no lists/blockquotes/codeblocks on them get removed
|
|
48
|
+
if(![ulStyle detectStyle:characterRange] && ![olStyle detectStyle:characterRange] && ![bqStyle detectStyle:characterRange] && ![cbStyle detectStyle:characterRange]) {
|
|
48
49
|
[indexesToBeRemoved addObject:@(characterRange.location)];
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
UnorderedListStyle *ulStyle = input->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
77
78
|
OrderedListStyle *olStyle = input->stylesDict[@([OrderedListStyle getStyleType])];
|
|
78
79
|
BlockQuoteStyle *bqStyle = input->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
80
|
+
CodeBlockStyle *cbStyle = input->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
79
81
|
NSMutableArray *indexesToBeInserted = [[NSMutableArray alloc] init];
|
|
80
82
|
NSRange preAddSelection = input->textView.selectedRange;
|
|
81
83
|
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
NSRange paragraphRange = [input->textView.textStorage.string paragraphRangeForRange:characterRange];
|
|
88
90
|
|
|
89
91
|
if(paragraphRange.length == 1) {
|
|
90
|
-
if([ulStyle detectStyle:characterRange] || [olStyle detectStyle:characterRange] || [bqStyle detectStyle:characterRange]) {
|
|
92
|
+
if([ulStyle detectStyle:characterRange] || [olStyle detectStyle:characterRange] || [bqStyle detectStyle:characterRange] || [cbStyle detectStyle:characterRange]) {
|
|
91
93
|
// we have an empty list or quote item with no space: add it!
|
|
92
94
|
[indexesToBeInserted addObject:@(paragraphRange.location)];
|
|
93
95
|
}
|
|
@@ -114,7 +116,7 @@
|
|
|
114
116
|
// additional check for last index of the input
|
|
115
117
|
NSRange lastRange = NSMakeRange(input->textView.textStorage.string.length, 0);
|
|
116
118
|
NSRange lastParagraphRange = [input->textView.textStorage.string paragraphRangeForRange:lastRange];
|
|
117
|
-
if(lastParagraphRange.length == 0 && ([ulStyle detectStyle:lastRange] || [olStyle detectStyle:lastRange] || [bqStyle detectStyle:lastRange])) {
|
|
119
|
+
if(lastParagraphRange.length == 0 && ([ulStyle detectStyle:lastRange] || [olStyle detectStyle:lastRange] || [bqStyle detectStyle:lastRange] || [cbStyle detectStyle:lastRange])) {
|
|
118
120
|
[TextInsertionUtils insertText:@"\u200B" at:lastRange.location additionalAttributes:nullptr input:input withSelection:NO];
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -146,19 +148,29 @@
|
|
|
146
148
|
styleRemovalRange = NSMakeRange(paragraphRange.location, 1);
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
[TextInsertionUtils replaceText:@"" at:removalRange additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
150
|
-
|
|
151
151
|
// and then remove associated styling
|
|
152
152
|
|
|
153
153
|
UnorderedListStyle *ulStyle = typedInput->stylesDict[@([UnorderedListStyle getStyleType])];
|
|
154
154
|
OrderedListStyle *olStyle = typedInput->stylesDict[@([OrderedListStyle getStyleType])];
|
|
155
155
|
BlockQuoteStyle *bqStyle = typedInput->stylesDict[@([BlockQuoteStyle getStyleType])];
|
|
156
|
+
CodeBlockStyle *cbStyle = typedInput->stylesDict[@([CodeBlockStyle getStyleType])];
|
|
157
|
+
|
|
158
|
+
if([cbStyle detectStyle:removalRange]) {
|
|
159
|
+
// code blocks are being handled differently; we want to remove previous newline if there is a one
|
|
160
|
+
if(range.location > 0) {
|
|
161
|
+
removalRange = NSMakeRange(removalRange.location - 1, removalRange.length + 1);
|
|
162
|
+
}
|
|
163
|
+
[TextInsertionUtils replaceText:@"" at:removalRange additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
164
|
+
return YES;
|
|
165
|
+
}
|
|
156
166
|
|
|
157
|
-
|
|
167
|
+
[TextInsertionUtils replaceText:@"" at:removalRange additionalAttributes:nullptr input:typedInput withSelection:YES];
|
|
168
|
+
|
|
169
|
+
if ([ulStyle detectStyle:styleRemovalRange]) {
|
|
158
170
|
[ulStyle removeAttributes:styleRemovalRange];
|
|
159
|
-
} else if([olStyle detectStyle:styleRemovalRange]) {
|
|
171
|
+
} else if ([olStyle detectStyle:styleRemovalRange]) {
|
|
160
172
|
[olStyle removeAttributes:styleRemovalRange];
|
|
161
|
-
} else if([bqStyle detectStyle:styleRemovalRange]) {
|
|
173
|
+
} else if ([bqStyle detectStyle:styleRemovalRange]) {
|
|
162
174
|
[bqStyle removeAttributes:styleRemovalRange];
|
|
163
175
|
}
|
|
164
176
|
|
|
@@ -166,5 +178,5 @@
|
|
|
166
178
|
}
|
|
167
179
|
return NO;
|
|
168
180
|
}
|
|
169
|
-
@end
|
|
170
181
|
|
|
182
|
+
@end
|
|
@@ -104,8 +104,8 @@ export const EnrichedTextInput = ({
|
|
|
104
104
|
setLink: (start, end, text, url) => {
|
|
105
105
|
Commands.addLink(nullthrows(nativeRef.current), start, end, text, url);
|
|
106
106
|
},
|
|
107
|
-
setImage: uri => {
|
|
108
|
-
Commands.addImage(nullthrows(nativeRef.current), uri);
|
|
107
|
+
setImage: (uri, width, height) => {
|
|
108
|
+
Commands.addImage(nullthrows(nativeRef.current), uri, width, height);
|
|
109
109
|
},
|
|
110
110
|
setMention: (indicator, text, attributes) => {
|
|
111
111
|
// Codegen does not support objects as Commands parameters, so we stringify attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useImperativeHandle","useMemo","useRef","EnrichedTextInputNativeComponent","Commands","normalizeHtmlStyle","jsx","_jsx","nullthrows","value","Error","warnAboutMissconfiguredMentions","indicator","console","warn","EnrichedTextInput","ref","autoFocus","editable","mentionIndicators","defaultValue","placeholder","placeholderTextColor","cursorColor","selectionColor","style","autoCapitalize","htmlStyle","onFocus","onBlur","onChangeText","onChangeHtml","onChangeState","onLinkDetected","onMentionDetected","onStartMention","onChangeMention","onEndMention","onChangeSelection","androidExperimentalSynchronousEvents","scrollEnabled","rest","nativeRef","normalizedHtmlStyle","measureInWindow","callback","current","measure","measureLayout","relativeToNativeComponentRef","onSuccess","onFail","setNativeProps","nativeProps","focus","blur","setValue","toggleBold","toggleItalic","toggleUnderline","toggleStrikeThrough","toggleInlineCode","toggleH1","toggleH2","toggleH3","toggleCodeBlock","toggleBlockQuote","toggleOrderedList","toggleUnorderedList","setLink","start","end","text","url","addLink","setImage","uri","addImage","setMention","attributes","parsedAttributes","JSON","stringify","addMention","startMention","includes","handleMentionEvent","e","mentionText","nativeEvent","mentionIndicator","handleLinkDetected","handleMentionDetected","payload","parse","onInputFocus","onInputBlur","isOnChangeHtmlSet","undefined","onMention"],"sourceRoot":"../../src","sources":["EnrichedTextInput.tsx"],"mappings":";;AAAA,SAGEA,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,gCAAgC,IACrCC,QAAQ,QAWH,oCAAoC;AAa3C,SAASC,kBAAkB,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"names":["useImperativeHandle","useMemo","useRef","EnrichedTextInputNativeComponent","Commands","normalizeHtmlStyle","jsx","_jsx","nullthrows","value","Error","warnAboutMissconfiguredMentions","indicator","console","warn","EnrichedTextInput","ref","autoFocus","editable","mentionIndicators","defaultValue","placeholder","placeholderTextColor","cursorColor","selectionColor","style","autoCapitalize","htmlStyle","onFocus","onBlur","onChangeText","onChangeHtml","onChangeState","onLinkDetected","onMentionDetected","onStartMention","onChangeMention","onEndMention","onChangeSelection","androidExperimentalSynchronousEvents","scrollEnabled","rest","nativeRef","normalizedHtmlStyle","measureInWindow","callback","current","measure","measureLayout","relativeToNativeComponentRef","onSuccess","onFail","setNativeProps","nativeProps","focus","blur","setValue","toggleBold","toggleItalic","toggleUnderline","toggleStrikeThrough","toggleInlineCode","toggleH1","toggleH2","toggleH3","toggleCodeBlock","toggleBlockQuote","toggleOrderedList","toggleUnorderedList","setLink","start","end","text","url","addLink","setImage","uri","width","height","addImage","setMention","attributes","parsedAttributes","JSON","stringify","addMention","startMention","includes","handleMentionEvent","e","mentionText","nativeEvent","mentionIndicator","handleLinkDetected","handleMentionDetected","payload","parse","onInputFocus","onInputBlur","isOnChangeHtmlSet","undefined","onMention"],"sourceRoot":"../../src","sources":["EnrichedTextInput.tsx"],"mappings":";;AAAA,SAGEA,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,gCAAgC,IACrCC,QAAQ,QAWH,oCAAoC;AAa3C,SAASC,kBAAkB,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAsH1D,MAAMC,UAAU,GAAQC,KAA2B,IAAQ;EACzD,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;EACvD;EAEA,OAAOD,KAAK;AACd,CAAC;AAED,MAAME,+BAA+B,GAAIC,SAAiB,IAAK;EAC7DC,OAAO,CAACC,IAAI,CACV,uCAAuCF,SAAS,8CAClD,CAAC;AACH,CAAC;AAID,OAAO,MAAMG,iBAAiB,GAAGA,CAAC;EAChCC,GAAG;EACHC,SAAS;EACTC,QAAQ,GAAG,IAAI;EACfC,iBAAiB,GAAG,CAAC,GAAG,CAAC;EACzBC,YAAY;EACZC,WAAW;EACXC,oBAAoB;EACpBC,WAAW;EACXC,cAAc;EACdC,KAAK;EACLC,cAAc,GAAG,WAAW;EAC5BC,SAAS,GAAG,CAAC,CAAC;EACdC,OAAO;EACPC,MAAM;EACNC,YAAY;EACZC,YAAY;EACZC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC,cAAc;EACdC,eAAe;EACfC,YAAY;EACZC,iBAAiB;EACjBC,oCAAoC,GAAG,KAAK;EAC5CC,aAAa,GAAG,IAAI;EACpB,GAAGC;AACmB,CAAC,KAAK;EAC5B,MAAMC,SAAS,GAAGxC,MAAM,CAAuB,IAAI,CAAC;EAEpD,MAAMyC,mBAAmB,GAAG1C,OAAO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,KAAM;IACbC,cAAc,EAAEA,cAAe;IAC/BC,SAAS,EAAEgB,mBAAoB;IAC/BsD,YAAY,EAAErE,OAAQ;IACtBsE,WAAW,EAAErE,MAAO;IACpBC,YAAY,EAAEA,YAAa;IAC3BC,YAAY,EAAEA,YAAa;IAC3BoE,iBAAiB,EAAEpE,YAAY,KAAKqE,SAAU;IAC9CpE,aAAa,EAAEA,aAAc;IAC7BC,cAAc,EAAE4D,kBAAmB;IACnC3D,iBAAiB,EAAE4D,qBAAsB;IACzCO,SAAS,EAAEb,kBAAmB;IAC9BlD,iBAAiB,EAAEA,iBAAkB;IACrCC,oCAAoC,EAClCA,oCACD;IACDC,aAAa,EAAEA,aAAc;IAAA,GACzBC;EAAI,CACT,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -105,10 +105,6 @@ export interface HtmlStyleInternal {
|
|
|
105
105
|
// This is a workaround for the fact that codegen does not support Records.
|
|
106
106
|
// On native Android side this will become a ReadableMap, on native iOS we can work with a folly::dynamic object.
|
|
107
107
|
mention?: UnsafeMixed;
|
|
108
|
-
img?: {
|
|
109
|
-
width?: Float;
|
|
110
|
-
height?: Float;
|
|
111
|
-
};
|
|
112
108
|
ol?: {
|
|
113
109
|
gapWidth?: Float;
|
|
114
110
|
marginLeft?: Float;
|
|
@@ -191,7 +187,12 @@ interface NativeCommands {
|
|
|
191
187
|
text: string,
|
|
192
188
|
url: string
|
|
193
189
|
) => void;
|
|
194
|
-
addImage: (
|
|
190
|
+
addImage: (
|
|
191
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
192
|
+
uri: string,
|
|
193
|
+
width: Float,
|
|
194
|
+
height: Float
|
|
195
|
+
) => void;
|
|
195
196
|
startMention: (
|
|
196
197
|
viewRef: React.ElementRef<ComponentType>,
|
|
197
198
|
indicator: string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["processColor","defaultStyle","h1","fontSize","bold","h2","h3","blockquote","borderColor","borderWidth","gapWidth","color","undefined","codeblock","borderRadius","backgroundColor","code","a","textDecorationLine","mention","
|
|
1
|
+
{"version":3,"names":["processColor","defaultStyle","h1","fontSize","bold","h2","h3","blockquote","borderColor","borderWidth","gapWidth","color","undefined","codeblock","borderRadius","backgroundColor","code","a","textDecorationLine","mention","ol","marginLeft","markerFontWeight","markerColor","ul","bulletColor","bulletSize","isMentionStyleRecord","mentionStyle","Array","isArray","keys","Object","length","every","key","convertToHtmlStyleInternal","style","mentionIndicators","mentionStyles","forEach","indicator","default","String","olStyles","assignDefaultValues","merged","parseStyle","name","value","endsWith","parseColors","finalStyle","tagName","tagStyle","entries","tagStyles","styleName","styleValue","normalizeHtmlStyle","converted","withDefaults"],"sourceRoot":"../../src","sources":["normalizeHtmlStyle.ts"],"mappings":";;AACA,SAA0BA,YAAY,QAAQ,cAAc;AAM5D,MAAMC,YAAiC,GAAG;EACxCC,EAAE,EAAE;IACFC,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDC,EAAE,EAAE;IACFF,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDE,EAAE,EAAE;IACFH,QAAQ,EAAE,EAAE;IACZC,IAAI,EAAE;EACR,CAAC;EACDG,UAAU,EAAE;IACVC,WAAW,EAAE,UAAU;IACvBC,WAAW,EAAE,CAAC;IACdC,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAEC;EACT,CAAC;EACDC,SAAS,EAAE;IACTF,KAAK,EAAE,OAAO;IACdG,YAAY,EAAE,CAAC;IACfC,eAAe,EAAE;EACnB,CAAC;EACDC,IAAI,EAAE;IACJL,KAAK,EAAE,KAAK;IACZI,eAAe,EAAE;EACnB,CAAC;EACDE,CAAC,EAAE;IACDN,KAAK,EAAE,MAAM;IACbO,kBAAkB,EAAE;EACtB,CAAC;EACDC,OAAO,EAAE;IACPR,KAAK,EAAE,MAAM;IACbI,eAAe,EAAE,QAAQ;IACzBG,kBAAkB,EAAE;EACtB,CAAC;EACDE,EAAE,EAAE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uB,OAAO,CAAClB,KAAK,CAAC,EAAE;IACvD,MAAMmB,SAA8B,GAAG,CAAC,CAAC;IAEzC,IAAIH,OAAO,KAAK,SAAS,EAAE;MACzB,KAAK,MAAM,CAACZ,SAAS,EAAEb,YAAY,CAAC,IAAII,MAAM,CAACuB,OAAO,CAACD,QAAQ,CAAC,EAAE;QAChEE,SAAS,CAACf,SAAS,CAAC,GAAG,CAAC,CAAC;QAEzB,KAAK,MAAM,CAACgB,SAAS,EAAEC,UAAU,CAAC,IAAI1B,MAAM,CAACuB,OAAO,CAClD3B,YACF,CAAC,EAAE;UACD4B,SAAS,CAACf,SAAS,CAAC,CAACgB,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;QACrE;MACF;MAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;MAC/B;IACF;IAEA,KAAK,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,IAAI1B,MAAM,CAACuB,OAAO,CAACD,QAAQ,CAAC,EAAE;MAC9DE,SAAS,CAACC,SAAS,CAAC,GAAGV,UAAU,CAACU,SAAS,EAAEC,UAAU,CAAC;IAC1D;IAEAN,UAAU,CAACC,OAAO,CAAC,GAAGG,SAAS;EACjC;EAEA,OAAOJ,UAAU;AACnB,CAAC;AAED,OAAO,MAAMO,kBAAkB,GAAGA,CAChCtB,KAAgB,EAChBC,iBAA2B,KACL;EACtB,MAAMsB,SAAS,GAAGxB,0BAA0B,CAACC,KAAK,EAAEC,iBAAiB,CAAC;EACtE,MAAMuB,YAAY,GAAGhB,mBAAmB,CAACe,SAAS,CAAC;EACnD,OAAOT,WAAW,CAACU,YAAY,CAAC;AAClC,CAAC","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ export interface EnrichedTextInputInstance extends NativeMethods {
|
|
|
18
18
|
toggleOrderedList: () => void;
|
|
19
19
|
toggleUnorderedList: () => void;
|
|
20
20
|
setLink: (start: number, end: number, text: string, url: string) => void;
|
|
21
|
-
setImage: (src: string) => void;
|
|
21
|
+
setImage: (src: string, width: number, height: number) => void;
|
|
22
22
|
startMention: (indicator: string) => void;
|
|
23
23
|
setMention: (indicator: string, text: string, attributes?: Record<string, string>) => void;
|
|
24
24
|
}
|
|
@@ -59,10 +59,6 @@ export interface HtmlStyle {
|
|
|
59
59
|
textDecorationLine?: 'underline' | 'none';
|
|
60
60
|
};
|
|
61
61
|
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
|
|
62
|
-
img?: {
|
|
63
|
-
width?: number;
|
|
64
|
-
height?: number;
|
|
65
|
-
};
|
|
66
62
|
ol?: {
|
|
67
63
|
gapWidth?: number;
|
|
68
64
|
marginLeft?: number;
|