Add SwiftData-backed image support #82
Open
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.
Motivation
takenote://image/<UUID>URLs for markdown preview and sharing.Description
NoteImageandNoteImageLinkwhereNoteImagestores image bytes with@Attribute(.externalStorage), amimeType, auuid, and areferenceCountfor simple garbage collection. (TakeNote/Models/NoteImage.swift,TakeNote/Models/NoteImageLink.swift).@Relationship var imageLinks: [NoteImageLink]?toNoteto track references from notes (model changes added to the appModelContainer). (TakeNote/Models/Note.swift,TakeNote/TakeNoteApp.swift).NoteImageManagerwithingestImage(from:note:),updateImageLinks(for:), andremoveImageLinks(for:)to ingest files, parsetakenote://image/<UUID>links, maintain reference counts, and delete unreferenced images. (TakeNote/Library/NoteImageManager.swift).TakeNoteImageURLProtocolthat serves image bytes fortakenote://image/<UUID>requests by fetching theNoteImagefrom the SwiftData container; hook registration into app init viaTakeNoteImageURLProtocolRegistrar.registerIfNeeded(container:). (TakeNote/Library/TakeNoteImageURLProtocol.swift,TakeNote/TakeNoteApp.swift).dropDestination(for: URL.self)andhandleImageDropwhich callsNoteImageManager.ingestImageand insertsmarkdown links at caret or appended in preview. (TakeNote/Views/NoteEditor/NoteEditor.swift).NoteImageManager.updateImageLinksand when notes are emptied from trash viaNoteImageManager.removeImageLinks. (TakeNote/Views/NoteList/NoteList.swift,TakeNote/TakeNoteVM.swift).ckBootstrapVersionCurrentso the Dev schema can be updated. (TakeNote/TakeNoteApp.swift).Testing
Codex Task