What programmatic access to we have to writing tools?
Asked on 2024-07-29
1 search
Programmatic access to writing tools is provided through various APIs and delegate methods. Here are the key points:
-
Integration with Native Text Views:
- Writing tools work seamlessly with
UITextView,NSTextView, andWKWebViewwhen using the appropriate configurations. - For
UITextViewandNSTextView, using TSC2 is recommended for the full experience. TSC1 provides a limited experience with results shown in a panel.
- Writing tools work seamlessly with
-
Custom Text Views:
- For custom text views, you can adopt the
NSServicesMenuRequesterprotocol to allow the system to read and write contents to the view. - Implement the
validRequestor(forSendType:returnType:)method to handle rich text and ensure the writing tools menu item appears in the context menu.
- For custom text views, you can adopt the
-
Controlling Behavior:
- Use the new text input traits API to customize the behavior of writing tools. You can set the behavior to
limitedfor a panel experience ornoneto opt out completely. - Specify if your text view supports rich text or tables using
RankToolsAllowedInputOptions.
- Use the new text input traits API to customize the behavior of writing tools. You can set the behavior to
-
Protecting Ranges:
- Delegate methods in
UITextFieldDelegateandNSTextViewDelegateallow you to specify ranges of text that should be ignored by writing tools, such as code blocks or quoted content.
- Delegate methods in
-
Observing Writing Tools Activity:
- Check or observe the
isWritingToolsActiveproperty to know if a writing tool session is active. - Use new delegate methods to manage app states during a writing tools session, such as pausing syncing to avoid conflicts.
- Check or observe the
For more detailed information, you can refer to the session "Get started with Writing Tools".
Relevant Sessions

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Get started with Writing Tools
Learn how Writing Tools help users proofread, rewrite, and transform text in your app. Get the details on how Writing Tools interact with your app so users can refine what they have written in any text view. Understand how text is retrieved and processed, and how to support Writing Tools in custom text views.
