writingToolsBehaviorについて教えて
Generated on 10/15/2024
1 search
The "writingToolsBehavior" refers to the behavior and configuration of the Writing Tools feature introduced by Apple at WWDC 2024. Writing Tools is a suite of features available in text fields across various apps, designed to help users proofread, rewrite, or transform text. It provides suggestions in line with the text, making it easy to review and integrate changes seamlessly.
Here are some key points about Writing Tools behavior:
-
Integration with Text Views: Writing Tools works with native text views like
UITextView
,NSTextView
, andWKWebView
. For full functionality,UITextView
andNSTextView
need to use TSC2. If using TSC1, the experience is limited to showing rewritten results in a panel. -
Behavior Customization: Developers can customize the behavior of Writing Tools using new text input traits APIs. By default, Writing Tools offers an inline experience, but developers can set it to a limited panel experience or opt out entirely.
-
Handling Rich Text: Writing Tools supports rich text by using attributed strings, preserving styles, links, and attachments in the rewritten text.
-
Protecting Text Ranges: Developers can specify text ranges to be ignored by Writing Tools, such as code blocks or quoted content, using new delegate methods.
-
Custom Text Views: For custom text views, Writing Tools can be integrated by adopting
UITextInteraction
orUITextSelectionDisplayInteraction
. This allows Writing Tools to appear in the context menu or color bar.
For more detailed information, you can refer to the session Get started with Writing Tools (07:03) which covers controlling the behavior of Writing Tools.