Skip to content
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

Add macOS support #149

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Add macOS support #149

wants to merge 18 commits into from

Conversation

tomekzaw
Copy link
Collaborator

@tomekzaw tomekzaw commented Feb 2, 2024

Details

Work in progress

Related Issues

GH_LINK

Manual Tests

Linked PRs

@matthargett
Copy link

visionOS support also coming? :)

@@ -9,6 +9,7 @@ type MarkdownStyle = MarkdownTextInputDecoractorView.MarkdownStyle;

const FONT_FAMILY_MONOSPACE = Platform.select({
ios: 'Courier',
macos: 'Courier',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
macos: 'Courier',
macos: 'SF Mono',

Can we use SF Mono as default for macOS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for this suggestion! Do we want to stick with Courier on iOS though?

Copy link

@Simek Simek Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done a bit of checking, and looks like SF fonts are not included by default for all systems to this day on both iOS and macOS.

In this case Menlo or Monaco could be a viable alternative for both platforms:

@hmbrg
Copy link

hmbrg commented Apr 27, 2024

Any updates on this one? MacOS support would be huge!

@tomekzaw
Copy link
Collaborator Author

After applying changes required by macOS itself (e.g. removing UIKit.h imports and replacing UIView with RCTUIView), there's a bug that prevents the user from typing more than only one character – all subsequent keypresses behave like pressing right arrow even though here I'm only pressing a key:

Screen.Recording.2024-10-10.at.20.21.15.mov

I managed to get it working by commenting out two swizzled methods in 7026df1 but then the formatting is applied with a slight delay:

Screen.Recording.2024-10-10.at.20.18.19.mov

So the formatting is incorrect for 1 frame:

Screenshot 2024-10-10 at 20 24 09

@Saadnajmi
Copy link

Hello! I would be interested if this PR was revived, though as I understand it, now this library is new architecture only?
Could I get an idea of any blockers y'all were seeing in macOS if there were any?

@tomekzaw
Copy link
Collaborator Author

@Saadnajmi Hey, nice to hear that!

Yep, as of today @expensify/react-native-live-markdown supports only the new architecture, see explanation in #634.

So one of the blockers is that we're still using method swizzling to override the default behavior when typing or updating the value from JS. There's a PR that eliminates method swizzling but there are still some details that need to be fixed: #520

As far as I remember, there were no blockers caused by react-native-macos so far, only some API differences like lack of UITextRange (we'll need to use NSRange instead) or some problems with valueForKey:.

I'm curious to know about your use case, feel free to send me a DM.

@Saadnajmi
Copy link

@Saadnajmi Hey, nice to hear that!

Yep, as of today @expensify/react-native-live-markdown supports only the new architecture, see explanation in #634.

So one of the blockers is that we're still using method swizzling to override the default behavior when typing or updating the value from JS. There's a PR that eliminates method swizzling but there are still some details that need to be fixed: #520

As far as I remember, there were no blockers caused by react-native-macos so far, only some API differences like lack of UITextRange (we'll need to use NSRange instead) or some problems with valueForKey:.

I'm curious to know about your use case, feel free to send me a DM.

The use case is mostly "it would be real great to have a proper open source richtextinput library for desktop". It feels like a common request for desktop apps specifically. We have some custom stuff internally, but it's not something that would be useful in open source IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants