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

Migrate away from TextKit 1 to TextKit 2 #145

Open
tomekzaw opened this issue Jan 31, 2024 · 0 comments · May be fixed by #524
Open

Migrate away from TextKit 1 to TextKit 2 #145

tomekzaw opened this issue Jan 31, 2024 · 0 comments · May be fixed by #524
Labels
enhancement New feature or request

Comments

@tomekzaw
Copy link
Collaborator

tomekzaw commented Jan 31, 2024

Objective

The objective of this task is to migrate away from using TextKit 1 APIs in iOS implementation of Live Markdown.

Current state

Currently, we access .layoutManager property which causes RCTUITextView to switch back to TextKit 1 compatibility mode with the following warning:

warning

UITextView 0x108021a00 is switching to TextKit 1 compatibility mode because its layoutManager was accessed.
Break on void _UITextViewEnablingCompatibilityMode(UITextView *__strong, BOOL) to debug.

Previous attempts

  1. Define class MarkdownTextLayoutManagerDelegate that conforms to NSTextLayoutManagerDelegate
  2. Create an instance of this class in [MarkdownTextInputDecoratorView didMoveToWindow:]
  3. Store the instance using a strong pointer as a private field
  4. Assign an instance of this class to _textView.textLayoutManager.delegate (this is a weak pointer!)
  5. Define class MarkdownBlockquoteTextLayoutFragment that inherits from NSTextLayoutFragment
  6. Implement drawAtPoint:inContext: to draw a rectangle and set a breakpoint inside
  7. Implement textLayoutManager:textLayoutFragmentForLocation:inTextElement: method that returns an instance of MarkdownBlockquoteTextLayoutFragment

This worked successfully, however there was a new issue with alternating content offset on each keypress (see #144 (comment) for details).

Resources

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

Successfully merging a pull request may close this issue.

1 participant