| @@ -32,12 +32,13 @@ struct EditorScreen: View { |
| 32 | |
32 | |
| 33 | /// One sheet at a time: two presenters on this screen interfere. |
33 | /// One sheet at a time: two presenters on this screen interfere. |
| 34 | enum Sheet: Identifiable { |
34 | enum Sheet: Identifiable { |
| 35 | case palette, conflict, syncCopies, recovery |
35 | case palette, conflict, syncCopies, recovery, refile |
| 36 | case block(BlockEdit) |
36 | case block(BlockEdit) |
| 37 | |
37 | |
| 38 | var id: String { |
38 | var id: String { |
| 39 | switch self { |
39 | switch self { |
| 40 | case .palette: "palette" |
40 | case .palette: "palette" |
| |
41 | case .refile: "refile" |
| 41 | case .conflict: "conflict" |
42 | case .conflict: "conflict" |
| 42 | case .syncCopies: "syncCopies" |
43 | case .syncCopies: "syncCopies" |
| 43 | case .recovery: "recovery" |
44 | case .recovery: "recovery" |
| @@ -105,6 +106,11 @@ struct EditorScreen: View { |
| 105 | case .conflict: ConflictSheet(session: session) |
106 | case .conflict: ConflictSheet(session: session) |
| 106 | case .syncCopies: SyncConflictSheet(session: session) { message = $0 } |
107 | case .syncCopies: SyncConflictSheet(session: session) { message = $0 } |
| 107 | case .recovery: RecoverySheet(session: session) { message = $0 } |
108 | case .recovery: RecoverySheet(session: session) { message = $0 } |
| |
109 | case .refile: |
| |
110 | RefileSheet(targets: workspace.refileTargets(openPath: session.path, document: session.document)) { target in |
| |
111 | self.sheet = nil |
| |
112 | if let target { refile(to: target) } |
| |
113 | } |
| 108 | case .block(let edit): |
114 | case .block(let edit): |
| 109 | BlockEditSheet(edit: edit, theme: MobileTheme(model.theme)) { content in |
115 | BlockEditSheet(edit: edit, theme: MobileTheme(model.theme)) { content in |
| 110 | self.sheet = nil |
116 | self.sheet = nil |
| @@ -192,7 +198,9 @@ struct EditorScreen: View { |
| 192 | editor.onRefreshSetup = { session.refreshSetup() } |
198 | editor.onRefreshSetup = { session.refreshSetup() } |
| 193 | editor.onAgenda = { start, count in model.agendaRequest = .init(start: start, count: count) } |
199 | editor.onAgenda = { start, count in model.agendaRequest = .init(start: start, count: count) } |
| 194 | editor.onAppCommand = { id in |
200 | editor.onAppCommand = { id in |
| 195 | if id == "app.toggle-markup" { |
201 | if id == "app.refile" { |
| |
202 | sheet = .refile |
| |
203 | } else if id == "app.toggle-markup" { |
| 196 | model.showMarkup.toggle() |
204 | model.showMarkup.toggle() |
| 197 | } else if MobileEditor.linkCommands.contains(id) { |
205 | } else if MobileEditor.linkCommands.contains(id) { |
| 198 | link(id) |
206 | link(id) |
| @@ -212,6 +220,20 @@ struct EditorScreen: View { |
| 212 | } |
220 | } |
| 213 | } |
221 | } |
| 214 | |
222 | |
| |
223 | extension EditorScreen { |
| |
224 | /// `org-refile` of the entry at the caret, to a target worked out again from the files |
| |
225 | /// now, as the agenda's Refile… does. |
| |
226 | func refile(to target: RefileTarget) { |
| |
227 | guard let editor, let path = session.path else { return } |
| |
228 | let caret = editor.editContext().caret |
| |
229 | guard let current = workspace.refileTargets(openPath: path, document: session.document).first(where: { $0.label == target.label }) else { |
| |
230 | message = "Can't find \(target.label) any more." |
| |
231 | return |
| |
232 | } |
| |
233 | message = session.refile(to: current, from: (path, caret)) |
| |
234 | } |
| |
235 | } |
| |
236 | |
| 215 | /// The editor's text view, with the Org key bar over the keyboard. |
237 | /// The editor's text view, with the Org key bar over the keyboard. |
| 216 | struct EditorTextView: UIViewRepresentable { |
238 | struct EditorTextView: UIViewRepresentable { |
| 217 | let editor: MobileEditor |
239 | let editor: MobileEditor |
| @@ -486,6 +508,7 @@ struct CommandPalette: View { |
| 486 | ("app.clock.goto", "Go to Clocked Entry"), ("app.clock.in-recent", "Clock In to Recent Entry…"), |
508 | ("app.clock.goto", "Go to Clocked Entry"), ("app.clock.in-recent", "Clock In to Recent Entry…"), |
| 487 | ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"), |
509 | ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"), |
| 488 | ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), |
510 | ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), |
| |
511 | ("app.refile", "Refile…"), |
| 489 | ("app.toggle-markup", "Show or Hide Markup"), |
512 | ("app.toggle-markup", "Show or Hide Markup"), |
| 490 | ("org.toggle-inline-images", "Show or Hide Inline Images"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), |
513 | ("org.toggle-inline-images", "Show or Hide Inline Images"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), |
| 491 | ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"), |
514 | ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"), |