The QuickLook API in the Scripting app provides a simple way to preview text, images, or files within your scripts. This is a wrapper around iOS QuickLook capabilities, allowing you to quickly display previews for a wide range of content types.
Each method returns a promise that resolves when the QuickLook view is dismissed, enabling you to chain actions or handle post-preview logic easily.
QuickLook.previewText(text: string): Promise<void>
Displays a preview of a text string.
text
(string): The text content to display in the preview.fullscreen
(boolean?): Whether preview in a fullscreen mode. Defaults to false.Promise<void>
: Resolves after the preview is dismissed.QuickLook.previewImage(image: UIImage): Promise<void>
Displays a preview of an image.
image
(UIImage): The image to display in the preview.fullscreen
(boolean?): Whether preview in a fullscreen mode. Defaults to false.Promise<void>
: Resolves after the preview is dismissed.QuickLook.previewURLs(urls: string[]): Promise<void>
Displays a preview of one or more files located at the given file URL strings.
urls
(string[]): An array of file URL strings. Each string should point to a valid file path or remote file that can be previewed by QuickLook.fullscreen
(boolean?): Whether preview in a fullscreen mode. Defaults to false.Promise<void>
: Resolves after the preview is dismissed.await
) will pause until the user dismisses the preview.try...catch
to handle errors such as invalid file paths or unsupported content types.With this API, you can integrate QuickLook previews seamlessly into your scripts, enhancing the user experience with minimal effort.