| @@ -32,12 +32,13 @@ struct EditorScreen: View { |
| 32 | 32 | |
| 33 | 33 | /// One sheet at a time: two presenters on this screen interfere. |
| 34 | 34 | enum Sheet: Identifiable { |
| 35 | | case palette, conflict, syncCopies, recovery |
| 35 | case palette, conflict, syncCopies, recovery, refile |
| 36 | 36 | case block(BlockEdit) |
| 37 | 37 | |
| 38 | 38 | var id: String { |
| 39 | 39 | switch self { |
| 40 | 40 | case .palette: "palette" |
| 41 | case .refile: "refile" |
| 41 | 42 | case .conflict: "conflict" |
| 42 | 43 | case .syncCopies: "syncCopies" |
| 43 | 44 | case .recovery: "recovery" |
| @@ -105,6 +106,11 @@ struct EditorScreen: View { |
| 105 | 106 | case .conflict: ConflictSheet(session: session) |
| 106 | 107 | case .syncCopies: SyncConflictSheet(session: session) { message = $0 } |
| 107 | 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 | 114 | case .block(let edit): |
| 109 | 115 | BlockEditSheet(edit: edit, theme: MobileTheme(model.theme)) { content in |
| 110 | 116 | self.sheet = nil |
| @@ -192,7 +198,9 @@ struct EditorScreen: View { |
| 192 | 198 | editor.onRefreshSetup = { session.refreshSetup() } |
| 193 | 199 | editor.onAgenda = { start, count in model.agendaRequest = .init(start: start, count: count) } |
| 194 | 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 | 204 | model.showMarkup.toggle() |
| 197 | 205 | } else if MobileEditor.linkCommands.contains(id) { |
| 198 | 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 | 237 | /// The editor's text view, with the Org key bar over the keyboard. |
| 216 | 238 | struct EditorTextView: UIViewRepresentable { |
| 217 | 239 | let editor: MobileEditor |
| @@ -486,6 +508,7 @@ struct CommandPalette: View { |
| 486 | 508 | ("app.clock.goto", "Go to Clocked Entry"), ("app.clock.in-recent", "Clock In to Recent Entry…"), |
| 487 | 509 | ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"), |
| 488 | 510 | ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), |
| 511 | ("app.refile", "Refile…"), |
| 489 | 512 | ("app.toggle-markup", "Show or Hide Markup"), |
| 490 | 513 | ("org.toggle-inline-images", "Show or Hide Inline Images"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), |
| 491 | 514 | ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"), |