oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2import SwiftUI
3
4public struct DocsDocumentMenu: View {
5 @FocusedValue(\.docsEditor) private var editor
6 public init() {}
7 public var body: some View {
8 Group {
9 Button { editor?.rename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) }
10 .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.detail?.can_write != true)
11 Button(docsMacString("Save")) { if let editor { Task { _ = await editor.model.saveAll() } } }
12 .keyboardShortcut("s").disabled(editor == nil)
13 Menu(docsMacString("Export")) {
14 Button(docsMacString("PDF…")) { editor?.exportRequest.wrappedValue = "pdf" }
15 Button(docsMacString("Markdown…")) { editor?.exportRequest.wrappedValue = "markdown" }
16 }.disabled(editor == nil || editor?.model.isDraft == true)
17 Button(docsMacString("Share…")) {
18 if let editor { Task { if await editor.model.saveAll() { editor.sharing.wrappedValue = true } } }
19 }.disabled(editor?.model.detail?.can_share != true)
20
21 Divider()
22
23 Button(docsMacString("Print…")) { editor?.exportRequest.wrappedValue = "print" }.keyboardShortcut("p").disabled(editor == nil || editor?.model.isDraft == true)
24
25 }
26 }
27}
28#endif
29