-
Notifications
You must be signed in to change notification settings - Fork 88
Customize formatting styles #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WOW 😮 so great!
- (void)textInputDidChange; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? I don't see any change inside implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Fabric, [RCTTextInputComponentView textInputDidChange]
is implemented in RCTTextInputComponentView.mm
but there's no such declaration in RCTTextInputComponentView
.
Since we want to call [_textInput textInputDidChange];
in the library code which imports the header, we need to add such declaration.
Without this line, the code won't compile due to an unknown selector.
ios/RCTMarkdownUtils.mm
Outdated
paragraphStyle.headIndent = 5; | ||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range]; | ||
[attributedString addAttribute:NSForegroundColorAttributeName value:_markdownStyle.preColor range:range]; | ||
// TODO: pass background color and ranges to layout manager | ||
} else if ([type isEqualToString:@"h1"]) { | ||
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; | ||
NSRange range2 = NSMakeRange(range.location - 2, range.length + 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can change the name of this variable to be more descriptive? Or add comment to indicate that we need to wrap the syntax #
as well as text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 74e9e75
#ifdef RCT_NEW_ARCH_ENABLED | ||
// implemented in MarkdownTextInputView updateProps: | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain me why we initialise markdown style in different place for fabric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm got it, I guess, viewManager is paper only 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ViewManager is indeed a concept from the old architecture but it turns out that they are still required on the new architecture.
First, I've tried to wrap the contents of this file in #ifndef RCT_NEW_ARCH_ENABLED
but it didn't work – the component was not properly registered. I think RCT_EXPORT_MODULE(MarkdownTextInputView)
is responsible for registering custom views.
Then, I've tried to wrap RCT_CUSTOM_VIEW_PROPERTY(markdownStyle, NSDictionary, MarkdownTextInputViewView)
and it also didn't work – the custom prop was not defined.
Finally, I decided to wrap only the implementation of the method; in fact this is necessary because initWithDictionary:
is defined only on Paper. The Fabric counterpart is initWithStyle:
which accepts a C++ struct generated by react-native-codegen. Since this struct is generated only on Fabric, it needs to be wrapped with #ifdef RCT_NEW_ARCH_ENABLED
. That's why it makes sense to put the declaration of initWithStyle:
in #else
branch.
e6163e6
to
4eccbcf
Compare
38fd8d0
to
890db3a
Compare
@@ -48,8 +52,10 @@ protected void onAttachedToWindow() { | |||
|
|||
if (previousSibling instanceof ReactEditText) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E/App Issue Closure Checklist
The checklist asks to point to a possible offending PR regarding fixed issue:
which we fixed in PR #590 by adding applyNewStyles()
at the end of this block.
Closes #20.