Handle local images in MarkupEditor
mainMarkupEditor supports 'local images'—images that reside on the local file system rather than being external URLs. When a user inserts a local image (via the Image Toolbar or by pasting), the editor creates a new image file with a unique UUID filename.
Key Behaviors:
- Default Location: By default, new local images are stored in the same directory as the text being edited.
- Notification: When a new local image is created, your
MarkupDelegateis notified via themarkupImageAdded(url: URL)method. You are responsible for managing these files (e.g., saving them alongside your document). - Enabling Support: Local image selection is disabled by default. To allow users to select images from their file system, you must set
MarkupEditor.allowLocalImages = trueearly in your application lifecycle.
On iOS and Mac Catalyst, enabling this adds a 'Select' button to the ImageViewController. On macOS, it adds a 'Select' button to the ImageItem dialog.
// Enable local image support early in the app lifecycle
MarkupEditor.allowLocalImages = true