Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Arc parity: Library ▸ Easels and Window ▸ View Easels…

Victora4463ed61d8f
diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swift
index 9925f1e..65dc0a0 100644
--- a/Sources/Cra/App/AppDelegate.swift
+++ b/Sources/Cra/App/AppDelegate.swift
@@ -1349,6 +1349,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
case "viewArchive": main.showLibrary(.archive)
case "viewDownloads": main.showLibrary(.downloads)
case "viewMedia": main.showLibrary(.media)
+ case "viewEasels": main.showLibrary(.easels)
case "goBack": main.currentBrowser?.goBack()
case "goForward": main.currentBrowser?.goForward()
case "pinTab": if let c = current, !main.isBlank { store.togglePinned(c) }
@@ -1603,7 +1604,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
window.addItem(std("Minimize Window", #selector(NSWindow.performMiniaturize(_:)), "m"))
window.addItem(std("Zoom", #selector(NSWindow.performZoom(_:))))
window.addItem(.separator())
- window.addItem(item("openLibrary")); window.addItem(item("viewDownloads")); window.addItem(item("viewMedia"))
+ window.addItem(item("openLibrary")); window.addItem(item("viewDownloads")); window.addItem(item("viewEasels")); window.addItem(item("viewMedia"))
window.addItem(.separator())
window.addItem(item("promoteLittleWindow")); window.addItem(item("littleWindowOpenInMenu")); window.addItem(item("closeLittleWindows"))
window.addItem(.separator())
diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swift
index bbe622e..103af57 100644
--- a/Sources/Cra/App/KeyBindings.swift
+++ b/Sources/Cra/App/KeyBindings.swift
@@ -235,6 +235,8 @@ final class KeyBindingRegistry {
// Window
KeyAction(id: "openLibrary", name: "Open Library…", section: .window, shortcuts: [Shortcut("l", cmdShift)], triggers: ["library"]),
KeyAction(id: "viewDownloads", name: "View Downloads…", section: .window, shortcuts: [Shortcut("j", cmdShift)], triggers: ["downloads"]),
+ // Arc: Window ▸ View Easels….
+ KeyAction(id: "viewEasels", name: "View Easels…", section: .window, shortcuts: [], triggers: ["easels"]),
// Arc: Window ▸ View Media….
KeyAction(id: "viewMedia", name: "View Media…", section: .window, shortcuts: [], triggers: ["media", "screenshots", "photos"]),
// Arc: Window ▸ Stay On Top.
diff --git a/Sources/Cra/UI/Easel/EaselBrowser.swift b/Sources/Cra/UI/Easel/EaselBrowser.swift
index be2267b..1ba3c90 100644
--- a/Sources/Cra/UI/Easel/EaselBrowser.swift
+++ b/Sources/Cra/UI/Easel/EaselBrowser.swift
@@ -123,6 +123,17 @@ enum EaselFiles {
return JSONStore<Easel>("Easels/\(id.uuidString).json")
}
static func load(_ id: UUID) -> Easel { store(id).load(or: { Easel(id: id) }) }
+
+ /// Every easel on disk, newest edit first, for Library ▸ Easels.
+ static func all() -> [(id: UUID, title: String, edited: Date)] {
+ let files = (try? FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: [.contentModificationDateKey])) ?? []
+ let decoder = JSONDecoder()
+ return files.filter { $0.pathExtension == "json" }.compactMap { url -> (id: UUID, title: String, edited: Date)? in
+ guard let data = try? Data(contentsOf: url), let e = try? decoder.decode(Easel.self, from: data) else { return nil }
+ let date = (try? url.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast
+ return (e.id, e.title, date)
+ }.sorted { $0.edited > $1.edited }
+ }
static func pictures(_ id: UUID) -> URL {
let u = folder.appendingPathComponent(id.uuidString, isDirectory: true)
try? FileManager.default.createDirectory(at: u, withIntermediateDirectories: true)
diff --git a/Sources/Cra/UI/Easel/EaselCanvasView.swift b/Sources/Cra/UI/Easel/EaselCanvasView.swift
index f60feec..52043fc 100644
--- a/Sources/Cra/UI/Easel/EaselCanvasView.swift
+++ b/Sources/Cra/UI/Easel/EaselCanvasView.swift
@@ -18,6 +18,8 @@ final class EaselCanvasView: NSView {
init(document: Easel) {
self.document = document
store = EaselFiles.store(document.id)
+ // A new easel is on disk from the start, so Library ▸ Easels lists it.
+ if !FileManager.default.fileExists(atPath: store.url.path) { store.saveNow(document) }
sheet = EaselSheetView(document: document)
super.init(frame: .zero)
wantsLayer = true
diff --git a/Sources/Cra/UI/Sidebar/LibraryView.swift b/Sources/Cra/UI/Sidebar/LibraryView.swift
index 99078ec..1dadc93 100644
--- a/Sources/Cra/UI/Sidebar/LibraryView.swift
+++ b/Sources/Cra/UI/Sidebar/LibraryView.swift
@@ -3,12 +3,13 @@ import SwiftUI
/// The Library's pages Cra has, in the order of Arc's rail (which also lists Easels and Boosts).
enum LibraryPage: String, CaseIterable {
- case media, downloads, spaces, archive
+ case media, downloads, easels, spaces, archive
var title: String {
switch self {
case .media: "Media"
case .downloads: "Downloads"
+ case .easels: "Easels"
case .spaces: "Spaces"
case .archive: "Archived Tabs"
}
@@ -17,15 +18,23 @@ enum LibraryPage: String, CaseIterable {
switch self {
case .media: "photo.on.rectangle"
case .downloads: "arrow.down.circle"
+ case .easels: "pencil.and.scribble"
case .spaces: "square.on.square"
case .archive: "archivebox"
}
}
- var selectedSymbol: String { self == .media ? "photo.fill.on.rectangle.fill" : symbol + ".fill" }
+ var selectedSymbol: String {
+ switch self {
+ case .media: "photo.fill.on.rectangle.fill"
+ case .easels: symbol
+ default: symbol + ".fill"
+ }
+ }
var searchPrompt: String {
switch self {
case .media: "Search Media…"
case .downloads: "Search Downloads…"
+ case .easels: "Search Easels…"
default: "Search Archive…"
}
}
@@ -276,6 +285,7 @@ private final class LibraryListView: NSView, NSTextFieldDelegate, NSTableViewDat
enum Row {
case header(String)
case media([MediaLibrary.File])
+ case easel(id: UUID, title: String, edited: Date)
case download(DownloadHistory.Entry)
case archived(ArchivedItem)
}
@@ -406,6 +416,16 @@ private final class LibraryListView: NSView, NSTextFieldDelegate, NSTableViewDat
}
empty.show(symbol: "arrow.down.circle", title: all.isEmpty ? "Nothing here yet!" : "No matches",
detail: all.isEmpty ? "Files you download show up here." : nil)
+ case .easels:
+ let all = EaselFiles.all()
+ let shown = needle.isEmpty ? all : all.filter { $0.title.lowercased().contains(needle) }
+ for (label, entries) in Self.grouped(shown, date: \.edited) {
+ out.append(.header(label))
+ out += entries.map { .easel(id: $0.id, title: $0.title, edited: $0.edited) }
+ }
+ // Arc's empty Easels page: "Out of ideas!"
+ empty.show(symbol: "pencil.and.scribble", title: all.isEmpty ? "Out of ideas!" : "No matches",
+ detail: all.isEmpty ? "Choose File ▸ New Easel to create a new Easel." : nil)
case .spaces:
break
case .archive:
@@ -529,6 +549,8 @@ private final class LibraryListView: NSView, NSTextFieldDelegate, NSTableViewDat
case .archive:
let store = store
MenuItems.add(menu, "Clear Archive", enabled: !store.archive.isEmpty) { store.clearArchive() }
+ case .easels:
+ MenuItems.add(menu, "New Easel") { [weak self] in self?.actions.performAction("newEasel") }
case .spaces:
return
}
@@ -552,6 +574,16 @@ private final class LibraryListView: NSView, NSTextFieldDelegate, NSTableViewDat
v.identifier = .init("header")
v.show(label, ink: colors.isDark ? .white : .black)
return v
+ case .easel(let id, let title, let edited):
+ let v = tableView.makeView(withIdentifier: .init("item"), owner: nil) as? LibraryItemCell ?? LibraryItemCell()
+ v.identifier = .init("item")
+ v.showEasel(title: title, edited: edited, colors: colors) { [store, actions] in
+ let url = Easel(id: id).url
+ if let tab = store.allTabs().first(where: { $0.tab?.url == url }) { store.selectTab(tab.id) }
+ else { _ = store.createTab(url: url, title: title, select: true) }
+ actions.closeLibrary()
+ }
+ return v
case .media(let files):
let v = tableView.makeView(withIdentifier: .init("media"), owner: nil) as? MediaRowCell ?? MediaRowCell()
v.identifier = .init("media")
@@ -585,7 +617,7 @@ extension LibraryListView: NSMenuDelegate {
let row = table.clickedRow
guard rows.indices.contains(row) else { return }
switch rows[row] {
- case .header, .media: break
+ case .header, .media, .easel: break
case .archived(let e):
let actions = actions, store = store
MenuItems.add(menu, "Restore") { actions.restoreArchived(e.id) }
@@ -693,6 +725,25 @@ private final class LibraryItemCell: NSView, NSDraggingSource {
apply(ink: ink)
}
+ /// An easel on Library ▸ Easels: its glyph, its title, when it was last edited.
+ func showEasel(title text: String, edited: Date, colors: SidebarColors, open: @escaping () -> Void) {
+ self.colors = colors
+ download = nil
+ restore = open
+ let ink: NSColor = colors.isDark ? .white : .black
+ tile.layer?.contents = nil
+ tile.layer?.backgroundColor = ink.withAlphaComponent(0.04).cgColor
+ icon.isHidden = false
+ icon.image = NSImage(systemSymbolName: "pencil.and.scribble", accessibilityDescription: "Easel")
+ title.stringValue = text
+ title.lineBreakMode = .byTruncatingTail
+ let f = RelativeDateTimeFormatter()
+ f.unitsStyle = .full
+ detail.stringValue = "Edited " + f.localizedString(for: edited, relativeTo: Date())
+ tip?.text = text
+ apply(ink: ink)
+ }
+
func showDownload(_ e: DownloadHistory.Entry, colors: SidebarColors) {
self.colors = colors
download = e
diff --git a/Tests/Scenarios/easel.scenario b/Tests/Scenarios/easel.scenario
index e0f09c5..64e6784 100644
--- a/Tests/Scenarios/easel.scenario
+++ b/Tests/Scenarios/easel.scenario
@@ -9,3 +9,5 @@ relaunch
wait 4
cra://debug?browserWindows=relaunched
expect-log browser windows relaunched: kind=normal listed=1 tabs=1 open=1
+cra://action/viewEasels
+wait 1
diff --git a/docs/arc-parity.md b/docs/arc-parity.md
index a27e3b2..bdbadb8 100644
--- a/docs/arc-parity.md
+++ b/docs/arc-parity.md
@@ -15,7 +15,7 @@ or Arc-only service), per CONTRIBUTING.md.
| Arc feature | Where in Arc | Cra | Notes |
|---|---|---|---|
| Boosts (per-site CSS/JS, colours, fonts, Zap) | URL bar ✎, Library ▸ Boosts, Settings ▸ Advanced "Enable Boosts" | missing | Biggest local feature still absent. |
-| Easels | File ▸ New Easel ⌃⇧E, Library ▸ Easels | partial | File ▸ New Easel (⌃⇧E): canvas, title, Pointer/Image/Text/Ellipse/Rectangle/Arrow/Freehand, pictures by file, paste or drop, saved per easel. Missing: Library ▸ Easels, the canvas's backdrop colour (Cra's is black), the text-size pill, captures into an easel; sharing is *skip* (cloud). |
+| Easels | File ▸ New Easel ⌃⇧E, Library ▸ Easels | partial | File ▸ New Easel (⌃⇧E): canvas, title, Pointer/Image/Text/Ellipse/Rectangle/Arrow/Freehand, pictures by file, paste or drop, saved per easel. Library ▸ Easels and Window ▸ View Easels… done. Missing: the canvas's backdrop colour (Cra's is black), the text-size pill, captures into an easel; sharing is *skip* (cloud). |
| Notes | File ▸ New Note ⌃⇧N, ⌃⌥N in split, Help ▸ Export Arc Notes | *skip* | Arc 1.172.1 no longer creates Notes: New Note is gone from the File menu and ⌃⇧N does nothing; only Help ▸ Export Arc Notes is left. |
| Library ▸ Media | Window ▸ View Media…, Library rail | done | Off until Show Media; ⋯ picks the folders (Cra has no captures folder). |
| Essential Keyboard Shortcuts window | Help ▸ Essential Keyboard Shortcuts, Settings ▸ Shortcuts | done | 475×462 floating dark panel, five rows of key caps, "View All ↗". |
@@ -125,7 +125,7 @@ in this sweep (Essential Shortcuts window, Library pages).
- Edit ▸ Find ▸ Use Selection to Find and Jump to Selection (⌘J).
- Easels, first version: File ▸ New Easel (⌃⇧E) opens a canvas in the tab (EaselBrowser, a page
engine of its own like WebKitBrowser, so sidebar.json is unchanged: the tab's address is
- easel://<id>, the drawing Easels/<id>.json).
+ easel://<id>, the drawing Easels/<id>.json); Library ▸ Easels and Window ▸ View Easels….
## Easels, measured (Arc 1.172.1, offline copy, 7 Nov 2026)