Image Playground integration: reader toolbar button ("Create Image
with Image Playground") opens the system generator, seeded with the
current text selection when there is one. Result uploads through the
same attachments.create/upload flow as everything else and inserts
Outline's own stable  reference
at the caret, via a new generic TextInsertionRequest/
pendingTextInsertion mechanism on NativeTextViewWrapper (nothing
previously let an embedder insert text into the editor from outside
at all).
Along the way, found and fixed a real pre-existing gap: standard
 Markdown images never rendered anywhere in the app -
services.images was never wired to anything but the no-op default, so
every such image silently fell back to dimmed raw source. Added
OutlineAPIClient.fetchAuthenticatedFile (Bearer-authed GET, for
attachments.redirect and similar) and OutlineImageProvider, a real
EmbeddedImageProvider backed by it, wired into every render surface
(reader, split-view preview, present sheet, collection overview).
Also fixes two Split View bugs surfaced while building this: the
raw-source pane was a plain SwiftUI TextEditor with no selection or
insertion hook, so the Image Playground button couldn't see a
highlighted selection there and generated images had nowhere to land;
replaced it with NativeTextViewWrapper in rawSourceMode (same engine,
no styling overhead, but now selection/insertion work like every
other pane). Also moved onSelectedTextChange's firing point earlier
in the delegate, since it was previously placed after the
rawSourceMode early-return and so could never fire for a raw-mode
editor at all. And images sized off a possibly-not-yet-settled text
container width during Split View's frequent per-keystroke rebuilds,
sticking at the wrong size until the document was reopened - now
re-measured once more a tick after layout settles.
Also reorganizes Settings: Command Palette and its full-workspace-
search toggle move out of Editor into a new Navigation section, since
they're about finding things, not about how documents are edited.
44 lines
1.5 KiB
Swift
44 lines
1.5 KiB
Swift
#if os(macOS)
|
|
import SwiftUI
|
|
import MarkdownEngine
|
|
import MarkdownEngineCodeBlocks
|
|
import OutlineKit
|
|
|
|
/// Read-only for now — document/overview editing isn't wired up yet. Uses
|
|
/// `NativeTextViewWrapper`'s own `isEditable: false`, not `.disabled(true)`:
|
|
/// the latter blocks ALL interaction including link clicks, since
|
|
/// `isSelectable` and link-opening both still need to work.
|
|
struct CollectionOverviewContent: View {
|
|
@State private var markdown: String
|
|
@State private var imageProvider: OutlineImageProvider
|
|
/// See `DocumentReaderView`'s `imageReloadTick`.
|
|
@State private var imageReloadTick = 0
|
|
|
|
init(apiClient: OutlineAPIClient, collection: OutlineCollection) {
|
|
_markdown = State(initialValue: collection.description ?? "")
|
|
_imageProvider = State(initialValue: OutlineImageProvider(apiClient: apiClient))
|
|
}
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
NativeTextViewWrapper(
|
|
text: $markdown,
|
|
configuration: .init(
|
|
services: .init(images: imageProvider, syntaxHighlighter: CodeSyntaxHighlighting.shared),
|
|
heightBehavior: .fitsContent
|
|
),
|
|
isEditable: false
|
|
)
|
|
.padding()
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
.animation(nil, value: imageReloadTick)
|
|
.task {
|
|
imageProvider.onImageLoaded = {
|
|
Task { @MainActor in imageReloadTick += 1 }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|