-
Notifications
You must be signed in to change notification settings - Fork 74
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
Replace the commit hook with a wrapper component based on display: contents
#566
base: main
Are you sure you want to change the base?
Conversation
const auto &mutableChild = | ||
std::const_pointer_cast<TextInputShadowNode>(child); |
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.
The logic here (not specifically these lines, in general) assumes that if the decorator node is mutable, the child text input is also mutable. I'm not actually sure whether this assumption always holds true.
It may make sense to check the children in the constructor and clone them if fragment.children
is null and the children list is not empty to ensure the child is mutable.
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.
This should be fine? Rerendering the decorator node should also rerender the text input underneath.
0edb26e
to
26f8433
Compare
android/src/main/java/com/expensify/livemarkdown/LiveMarkdownModule.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/expensify/livemarkdown/MarkdownTextInputDecoratorViewManagerSpec.java
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
…downSpec/MarkdownTextInputDecoratorShadowNode.cpp Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
const auto &children = getChildren(); | ||
react_native_assert( | ||
children.size() == 1 && | ||
"MarkdownTextInputDecoratorView received wrong number of children"); | ||
|
||
const auto child = | ||
std::static_pointer_cast<const TextInputShadowNode>(children.at(0)); | ||
|
||
child->ensureUnsealed(); |
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.
Let's move this common logic to a utility function called something like getMutableTextInputShadowNodeFromChildren
but in a separate PR
// apply markdown formatting before measuring the child | ||
const auto &mutableChild = | ||
std::const_pointer_cast<TextInputShadowNode>(child); | ||
applyMarkdown(mutableChild, layoutContext); |
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.
TODO: rename applyMarkdown
so it explicitly says what it does under the hood
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.
Is applyMarkdownStylesToTextInputState
ok?
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.
// this can possibly be optimized | ||
RCTMarkdownStyle *markdownStyle = | ||
[[RCTMarkdownStyle alloc] initWithStruct:markdownProps.markdownStyle]; | ||
RCTMarkdownUtils *utils = [[RCTMarkdownUtils alloc] init]; | ||
[utils setMarkdownStyle:markdownStyle]; | ||
[utils setParserId:[NSNumber numberWithInt:markdownProps.parserId]]; |
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.
TODO: store this somewhere pretty please in a separate PR
Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
…downSpec/MarkdownTextInputDecoratorShadowNode.cpp Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
…downSpec/MarkdownTextInputDecoratorShadowNode.cpp Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
...w_arch/react/renderer/components/RNLiveMarkdownSpec/MarkdownTextInputDecoratorShadowNode.cpp
Outdated
Show resolved
Hide resolved
…downSpec/MarkdownTextInputDecoratorShadowNode.cpp Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
Details
React Native 0.77 comes with support for
display: contents
which would allow to make a wrapper component that doesn't impact layout in any way. This can be used to replace the commit hook to apply markdown styles without cloning the tree.Related Issues
GH_LINK
Manual Tests
Linked PRs