#if os(macOS) import SwiftUI public struct DocsDocumentMenu: View { @FocusedValue(\.docsEditor) private var editor public init() {} public var body: some View { Group { Button { editor?.rename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) } .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.detail?.can_write != true) Button(docsMacString("Save")) { if let editor { Task { _ = await editor.model.saveAll() } } } .keyboardShortcut("s").disabled(editor == nil) Menu(docsMacString("Export")) { Button(docsMacString("PDF…")) { editor?.exportRequest.wrappedValue = "pdf" } Button(docsMacString("Markdown…")) { editor?.exportRequest.wrappedValue = "markdown" } }.disabled(editor == nil || editor?.model.isDraft == true) Button(docsMacString("Share…")) { if let editor { Task { if await editor.model.saveAll() { editor.sharing.wrappedValue = true } } } }.disabled(editor?.model.detail?.can_share != true) Divider() Button(docsMacString("Print…")) { editor?.exportRequest.wrappedValue = "print" }.keyboardShortcut("p").disabled(editor == nil || editor?.model.isDraft == true) } } } #endif