WWDC24: Get started with Writing Tools | Apple

Apple Developer
11 Jun 202412:24

Summary

TLDRIn this session, Liu Dongyuan introduces Writing Tools, a suite of features available across iOS, iPadOS, and macOS apps to help users proofread, rewrite, summarize, and transform text. The video explains how Writing Tools seamlessly integrates into native text views, making it easy to review and apply suggestions. It also highlights how to implement Writing Tools in apps, customize its behavior, and support non-editable or custom text views. The session offers useful insights on managing text transformations, handling rich text, and protecting specific text ranges, providing a comprehensive guide for developers to enhance their apps with Writing Tools.

Takeaways

  • 😀 Writing Tools is a suite of features that helps users proofread, rewrite, and transform text in iOS, iPadOS, and macOS apps.
  • 😀 It appears in native text views, offering suggestions for proofreading, rewriting, summarizing, and transforming text into lists or tables.
  • 😀 Writing Tools can handle both editable and non-editable text, showing results in a panel where users can copy or share the suggestions.
  • 😀 On macOS, Writing Tools appears in the context menu and the Edit menu, and users can invoke it from the callout bar in iOS and iPadOS.
  • 😀 It supports rich text, preserving styles, links, and attachments, and integrates with NSTextList and NSTextTable for list and table transformations.
  • 😀 Writing Tools works automatically with supported text views like UITextView, NSTextView, and WKWebView, as long as TextKit 2 is being used.
  • 😀 New delegate methods allow developers to pause syncing or editing when Writing Tools is active, and restore app states afterward.
  • 😀 Custom text views can easily integrate Writing Tools, with support for iOS and macOS apps by adopting specific text interaction protocols.
  • 😀 Developers can customize Writing Tools' behavior using options like .limited or .none for a more tailored experience, including handling rich text or tables.
  • 😀 Writing Tools automatically manages undo actions, allowing users to revert changes and providing a seamless editing experience.
  • 😀 To ignore specific text ranges, developers can use delegate methods to prevent Writing Tools from making changes to parts like code blocks or quoted text.

Q & A

  • What is Writing Tools and how does it help users?

    -Writing Tools is a suite of features available in text views across apps on iOS, iPadOS, and macOS. It helps users proofread, rewrite, transform, and summarize their text. The tool provides in-line suggestions for proofreading, rewriting text to make it more concise or professional, and even converts text into key points, lists, or tables.

  • Where can Writing Tools be accessed in native text views?

    -Writing Tools appears on top of the keyboard in native text views, such as UITextView, NSTextView, and WKWebView, when text is selected. It also shows up in the callout bar next to options like 'Cut,' 'Copy,' and 'Paste' and in the context menu on macOS.

  • Can Writing Tools work with non-editable text?

    -Yes, Writing Tools can also work with non-editable text. In these cases, the results are shown in the Writing Tools panel, and the user can copy or share the results, but the text itself is not directly modified.

  • How can Writing Tools help in rewriting text?

    -Writing Tools can help rewrite text by making it more friendly, professional, or concise. The tool offers suggestions to improve the tone and style of the text and helps users transform their content to meet specific communication goals.

  • What options do developers have to control how Writing Tools behaves in their app?

    -Developers can control the behavior of Writing Tools by using the 'writingToolsBehavior' property. They can set it to '.limited' for a panel experience or '.none' to opt-out of Writing Tools completely. Additionally, developers can specify if their text view supports rich text or tables using the 'writingToolsAllowedInputOptions' property.

  • What is TextKit 2 and how does it affect Writing Tools integration?

    -TextKit 2 is a framework that provides better support for features like Writing Tools in text views. If an app uses TextKit 2, it supports the full Writing Tools experience, including advanced features like rich text handling, tables, and lists. However, if TextKit 1 is used, the experience is limited, and the user only sees rewritten text in a panel.

  • How does Writing Tools handle rich text and tables?

    -Writing Tools supports rich text by using attributed strings, preserving styles, links, and attachments in rewritten text. For tables and lists, Writing Tools sends NSTextList and NSTextTable to the text storage if the text view supports these features. Developers can configure their text view to handle or avoid these elements.

  • What should developers do to make Writing Tools compatible with their custom text views?

    -To make Writing Tools work with custom text views, developers need to ensure their text view adopts UITextInteraction (on iOS and iPadOS) or NSServicesMenuRequestor (on macOS). This allows the app to interact with the system and enable Writing Tools in the context menu. Developers may also need to implement specific delegate methods and properties to ensure proper functionality.

  • How can developers specify ranges of text to be ignored by Writing Tools?

    -Developers can specify ranges of text to be ignored by Writing Tools, such as code blocks or quoted text, using delegate methods in UITextViewDelegate and NSTextViewDelegate. By returning the ranges that should not be modified, Writing Tools will skip those sections and avoid suggesting changes.

  • What happens to text storage when Writing Tools is active?

    -When Writing Tools is active, it alters the text storage directly. Therefore, developers should avoid persisting the text storage during a Writing Tools session. Changes made by Writing Tools are also pushed to the undo stack, allowing users to revert changes if necessary.

Outlines

plate

此内容仅限付费用户访问。 请升级后访问。

立即升级

Mindmap

plate

此内容仅限付费用户访问。 请升级后访问。

立即升级

Keywords

plate

此内容仅限付费用户访问。 请升级后访问。

立即升级

Highlights

plate

此内容仅限付费用户访问。 请升级后访问。

立即升级

Transcripts

plate

此内容仅限付费用户访问。 请升级后访问。

立即升级
Rate This

5.0 / 5 (0 votes)

相关标签
Writing ToolsText EditingiOSiPadOSmacOSProofreadingRewritingTextViewsDeveloper ToolsApp DevelopmentUser Experience
您是否需要英文摘要?