feat: support opt-in remote Markdown images - #1
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “remote Markdown images” capability to the in-app Markdown preview by plumbing an editor setting into the Markdown rendering policy and introducing an HTTP(S) attachment loader, while keeping Quick Look’s rendering path unchanged and bumping version/build metadata.
Changes:
- Add
allowsRemoteImagessetting (persistence + settings import/export) and expose it in the settings UI. - Route Markdown preview image attachment loading through a new loader that can fetch HTTP(S) images when policy allows.
- Update localization strings and bump app/extension version/build values.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/TildeEditorTests/EditorSettingsTests.swift | Verifies the new allowsRemoteImages setting persists and round-trips via snapshot export/import. |
| Tests/TildeCoreTests/MarkdownPolicyTests.swift | Extends policy tests to cover enabling remote resources. |
| Sources/TildeMarkdown/SecureAttachmentLoader.swift | Adds a Markdown-aware attachment loader plus a remote HTTP(S) image loader with MIME + pixel/byte validation. |
| Sources/TildeMarkdown/MarkdownPreviewView.swift | Switches preview to the new attachment loader and forces refresh when remote-resource policy toggles. |
| Sources/TildeEditor/EditorSettingsView.swift | Adds a toggle for “Load remote images” with explanatory caption text. |
| Sources/TildeEditor/EditorSettings.swift | Implements the new persisted setting and includes it in settings snapshots. |
| Sources/TildeCore/Resources/zh-Hans.lproj/Localizable.strings | Adds localized strings for the new toggle and description. |
| Sources/TildeCore/Resources/en.lproj/Localizable.strings | Adds English strings for the new toggle and description. |
| Sources/TildeApplication/DocumentRootView.swift | Plumbs the new setting into MarkdownPolicy for the preview view. |
| scripts/build-dmg.sh | Updates default VERSION to 0.1.4. |
| Host/TildeHost.xcodeproj/project.pbxproj | Bumps MARKETING_VERSION to 0.1.4 and build to 5 for app + extension. |
| Host/App/Tilde.entitlements | Enables the app sandbox network client entitlement needed for remote fetches. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+107
to
+126
| struct MarkdownAttachmentLoader: AttachmentLoader { | ||
| let local: SecureAttachmentLoader | ||
| let policy: MarkdownPolicy | ||
|
|
||
| func attachment( | ||
| for url: URL, | ||
| text: String, | ||
| environment: ColorEnvironmentValues | ||
| ) async throws -> LocalImageAttachment { | ||
| switch url.scheme?.lowercased() { | ||
| case "http", "https": | ||
| guard policy.allowsRemoteResource(url) else { | ||
| throw SecureAttachmentLoader.Blocked.resourceLoadingDisabled | ||
| } | ||
| return try await RemoteImageAttachmentLoader(policy: policy).attachment( | ||
| for: url, | ||
| text: text, | ||
| environment: environment | ||
| ) | ||
| default: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The preview previously routed every image through the local-only attachment resolver, so remote HTTP(S) images were rejected even though the policy exposed a remote-resource flag.
Validation
swift test— 94 tests passedscripts/verify-host.sh Debug— passedgit diff --check— passedThe pre-existing uncommitted README change was intentionally left out of this PR.