Commit 7f0c7bf3c7

7f0c7bf3c773402711ac74c8f850bf858319580f

parent: fc3ddfcd58

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-26 06:02 UTC

iOS editor: Export and Recovery Versions in Commands on iPhone

Export… and Export Subtree… are in the editor's Commands list, opening
the export screen and the subtree export. On iPhone the toolbar has no
Export or Recovery Versions button, so the file name shows at every
text size; on iPad both stay in the toolbar.

Closes #236

Layout: unified · split

Changed files (5)
Sources/OrgApp/CommandTitles.swift +1 · view
@@ -90,6 +90,7 @@ enum CommandTitles {
9090 String(localized: "Expand Table Columns", comment: "Command title"),
9191 String(localized: "Expand Word", comment: "Command title"),
9292 String(localized: "Export Agenda Files to iCalendar", comment: "Command title"),
93 String(localized: "Export Subtree…", comment: "Command title"),
9394 String(localized: "Export Table as TSV…", comment: "Command title"),
9495 String(localized: "Export Table to File…", comment: "Command title"),
9596 String(localized: "Export to HTML", comment: "Command title"),
Sources/OrgstarMobile/EditorScreen.swift +19 −4 · view
@@ -83,7 +83,7 @@ struct EditorScreen: View {
8383 }
8484
8585 enum Sheet: Identifiable {
86 case palette, conflict, syncCopies, recovery
86 case palette, conflict, syncCopies, recovery, export
8787 /// `app.refile`, `app.refile.copy` or `app.refile.goto`.
8888 case refile(String)
8989 case block(BlockEdit)
@@ -102,6 +102,7 @@ struct EditorScreen: View {
102102 case .conflict: "conflict"
103103 case .syncCopies: "syncCopies"
104104 case .recovery: "recovery"
105 case .export: "export"
105106 case .block(let edit): "block \(edit.range)"
106107 case .columns: "columns"
107108 case .plot: "plot"
@@ -115,6 +116,9 @@ struct EditorScreen: View {
115116
116117 private var pane: EditorPane? { givenPane ?? holder.pane }
117118
119 /// Export Subtree…, which shows the export formats for the subtree at the caret.
120 static let exportSubtreeCommand = "app.export-subtree-dialog"
121
118122 /// The pane commands, as the Mac's View menu has them.
119123 static let paneCommands = ["app.split-right", "app.split-below", "app.pane-next", "app.pane-close", "app.pane-only"]
120124
@@ -138,7 +142,8 @@ struct EditorScreen: View {
138142 if syncCopies > 0 {
139143 Button("Resolve Sync Conflicts…", systemImage: "doc.on.doc") { sheet = .syncCopies }
140144 }
141 if recoveries > 0 {
145 // On iPhone, in Commands, so the file name has room at the largest text sizes.
146 if recoveries > 0, sizeClass == .regular {
142147 Button("Recovery Versions…", systemImage: "clock.arrow.circlepath") { sheet = .recovery }
143148 }
144149 Button("Find", systemImage: "magnifyingglass") {
@@ -152,7 +157,8 @@ struct EditorScreen: View {
152157 } primaryAction: {
153158 editor?.run("edit.undo")
154159 }
155 if let tree = session.document(of: path)?.tree {
160 // On iPhone, Export is in Commands, so the file name has room.
161 if sizeClass == .regular, let tree = session.document(of: path)?.tree {
156162 ExportMenu(path: path, tree: tree, report: { message = $0 }, exportSubtree: exportSubtree)
157163 }
158164 Button("Commands", systemImage: "command") { sheet = .palette }
@@ -220,6 +226,8 @@ struct EditorScreen: View {
220226 PlotScreen(plot: plot)
221227 case .crypt(let request):
222228 CryptScreen(request: request, session: session, editor: editor) { message = $0 }
229 case .export:
230 if let tree = session.document(of: path)?.tree { ExportScreen(path: path, tree: tree) { message = $0 } }
223231 case .exportSubtree(let caret):
224232 if let tree = session.document(of: path)?.tree { SubtreeExportScreen(path: path, tree: tree, caret: caret) }
225233 case .backlinks:
@@ -449,6 +457,10 @@ struct EditorScreen: View {
449457 if let caret = self.editor?.editContext().caret { message = session.archive(from: (path, caret)) }
450458 } else if id == "app.copy-rich-text" {
451459 if let text = session.document(of: path)?.text { message = ExportItems.copy(path: path, text: text, theme: model.theme) }
460 } else if id == "app.export-dialog" {
461 sheet = .export
462 } else if id == EditorScreen.exportSubtreeCommand {
463 exportSubtree()
452464 } else if id == "app.export.html-open" {
453465 exportHTMLAndOpen()
454466 } else if id == "app.export-body-only" {
@@ -1020,7 +1032,8 @@ struct CommandPalette: View {
10201032 ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"),
10211033 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"),
10221034 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"),
1023 ("app.archive", "Archive Subtree"), ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"),
1035 ("app.archive", "Archive Subtree"), ("app.export-dialog", "Export…"), ("app.export-subtree-dialog", "Export Subtree…"),
1036 ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"),
10241037 ("app.export-body-only", "Turn Body-Only Export On or Off"),
10251038 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"),
10261039 ("app.publish", "Publish Project…"), ("app.publish.all", "Publish All Projects"), ("app.publish.current-file", "Publish Current File"),
@@ -1112,6 +1125,8 @@ struct CommandPalette: View {
11121125 switch id {
11131126 case "app.recovery": return recoveries > 0 ? nil : String(localized: "No Recovery Versions")
11141127 case "app.sync-conflicts": return syncCopies > 0 ? nil : String(localized: "No sync conflict copies", comment: "Why Resolve Sync Conflicts… is greyed in the Commands list")
1128 case EditorScreen.exportSubtreeCommand:
1129 return ExportScope.subtree(context.text, at: context.caret) != nil ? nil : String(localized: "Not in a subtree", comment: "Why Export Subtree… is greyed in the Commands list")
11151130 default: return editor.applies(id, in: context) ? nil : CommandReason.reason(for: id, in: context)
11161131 }
11171132 }
Sources/OrgstarMobile/MobileEditor.swift +1 −1 · view
@@ -508,7 +508,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
508508 case "app.word-count", "app.recovery", "app.sync-conflicts", "app.attach.photo", "app.attach.camera", "app.attach.scan": return onAppCommand != nil
509509 case _ where id.hasPrefix(NamedMacros.commandPrefix): return true
510510 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
511 case "app.copy-rich-text", "app.export.html-open", "app.export-body-only", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil
511 case "app.export-dialog", "app.export-subtree-dialog", "app.copy-rich-text", "app.export.html-open", "app.export-body-only", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil
512512 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil
513513 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
514514 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
Tests/OrgAppTests/EditorCommandListTests.swift added +24 · view
@@ -0,0 +1,24 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5/// The iOS editor's Commands list, read from its source as CommandTitleTests does: the target
6/// isn't built by `swift test`.
7struct EditorCommandListTests {
8 static let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
9
10 static func viewCommands() throws -> [(id: String, title: String)] {
11 let source = try String(contentsOf: root.appendingPathComponent("Sources/OrgstarMobile/EditorScreen.swift"), encoding: .utf8)
12 return source.matches(of: /\("((?:app|org|edit|editor|view)\.[^"]+)", "([^"\\]+)"\)/).map { (String($0.1), String($0.2)) }
13 }
14
15 /// #236: Export is in Commands, under Export, since the iPhone toolbar has no room for it.
16 @Test func exportIsInTheEditorsCommands() throws {
17 let commands = try Self.viewCommands()
18 #expect(commands.contains { $0 == ("app.export-dialog", "Export…") })
19 #expect(commands.contains { $0 == ("app.export-subtree-dialog", "Export Subtree…") })
20 let export = try #require(CommandGroups.commandList.firstIndex { $0.prefixes.contains("app.export") })
21 #expect(CommandGroups.group(of: "app.export-dialog", in: CommandGroups.commandList) == export)
22 #expect(CommandGroups.group(of: "app.export-subtree-dialog", in: CommandGroups.commandList) == export)
23 }
24}
docs/manual/guide/14-ios.org +8 −6 · view
@@ -57,11 +57,13 @@ The toolbar has:
5757- Conflict :: shown while the file and your edits conflict; opens the conflict sheet.
5858- Find :: the system find bar. The result shown is selected, and opened when it is in folded text.
5959- Resolve Sync Conflicts… :: shown while the file has Syncthing conflict copies; see Conflicts below.
60- Recovery Versions… :: shown while the recovery folder holds versions of the file; see Conflicts below.
60- Recovery Versions… :: on iPad, shown while the recovery folder holds versions of the file; see Conflicts below.
6161- Undo :: touch and hold it for Redo.
62- Export :: the export formats, as in the reader; see Export below.
62- Export :: on iPad, the export formats; see Export below.
6363- Commands :: every command; see Commands below.
6464
65On iPhone, Recovery Versions…, Export… and Export Subtree… are in Commands, so the file name has room at every text size.
66
6567The key bar holds what you repeat at the caret while typing, the toolbar what acts on the whole file, and Commands everything else.
6668
6769Messages from commands show at the top of the editor and the column view, and at the bottom of the reader, the agenda and the board, for a few seconds; tap one to dismiss it. VoiceOver reads each message as it appears. An error opening, saving or reading a file shows what failed on its first line, such as =Couldn't Save File=.
@@ -176,7 +178,7 @@ Commands, in the key bar and in the toolbar of the editor, the reader and the ag
176178
177179Named keyboard macros are listed by name under Edit, and Next Snippet Field and Previous Snippet Field under Text with the other snippet commands. In the editor, a command that doesn't apply at the caret is listed greyed, with the reason, such as =Not in a list= or =No table at point=, so a search finds everything the editor can do. With a hardware keyboard attached, each command shows its Emacs key.
178180
179The reader's list has Find, Outline, Export…, Show or Hide Markup, Capture… and the clock commands that need no caret. The agenda's has its views, Tags and Properties…, Search…, Save as View…, Today, Earlier, Later, Go to Date…, Log Mode, Filter…, Select, Board, Capture… and the same clock commands.
181The editor's list has Export… and Export Subtree… under Export. The reader's list has Find, Outline, Export…, Show or Hide Markup, Capture… and the clock commands that need no caret. The agenda's has its views, Tags and Properties…, Search…, Save as View…, Today, Earlier, Later, Go to Date…, Log Mode, Filter…, Select, Board, Capture… and the same clock commands.
180182
181183When a command asks a question, a sheet opens:
182184
@@ -397,11 +399,11 @@ The app icon's badge counts the entries in the agenda's Overdue section that are
397399
398400* Export
399401
400Export (in the editor's toolbar, and Export… in the reader's Commands) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX or ASCII export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " or "Can't export to plain text: " and the reason show at the bottom of the screen.
402Export (in the editor's toolbar on iPad, and Export… in the Commands of the editor and the reader) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX or ASCII export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " or "Can't export to plain text: " and the reason show at the bottom of the screen.
401403
402404PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. PDF through LaTeX isn't available on iOS.
403405
404Body Only in the Export menu leaves out the title and the page around the text in HTML, Markdown, LaTeX and Plain Text (ASCII), and is kept for each file; the other formats say they have no body-only export while it is on. Export Subtree…, in the editor's Export menu, shares the subtree at the caret in any of the formats.
406Body Only in the Export menu leaves out the title and the page around the text in HTML, Markdown, LaTeX and Plain Text (ASCII), and is kept for each file; the other formats say they have no body-only export while it is on. Export Subtree…, in the editor's Commands and its Export menu on iPad, shares the subtree at the caret in any of the formats.
405407
406408The Export menu also has Export Agenda Files to iCalendar, which writes an =.ics= beside each agenda file, and Combine Agenda Files into iCalendar, which shares one calendar of them all. Commands has these, Copy as Rich Text, and Export to HTML and Open, which shows the HTML export in Quick Look. Without orgstar+, the Export menu's items that need it end in "(orgstar+)" and open the orgstar+ screen.
407409
@@ -438,7 +440,7 @@ The version you don't keep goes to the recovery folder.
438440
439441Resolve Sync Conflicts… (in the editor's toolbar while there are copies, and in Commands) lists Syncthing's conflict copies of the file (=name.sync-conflict-…=), each compared with the file, with Keep File, Merge and Use Copy. The copy goes to the recovery folder and is removed. When a file with conflict copies opens in the editor, a message says how many there are.
440442
441Recovery Versions… (in the editor's toolbar while there are versions, and in Commands) lists the versions of the file kept in the recovery folder, newest first, each compared with the editor's text. Restore puts a version's text in the editor as an edit you can undo.
443Recovery Versions… (in Commands, and in the editor's toolbar on iPad while there are versions) lists the versions of the file kept in the recovery folder, newest first, each compared with the editor's text. Restore puts a version's text in the editor as an edit you can undo.
442444
443445See [[file:15-alongside-emacs.org][Working alongside Emacs and other tools]] for how merging and recovery work.
444446
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form