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: Easels, first version (File ▸ New Easel ⌃⇧E)
Victor719a4bf1ef1f
diff --git a/Packages/CraCore/Sources/CraCore/Easel.swift b/Packages/CraCore/Sources/CraCore/Easel.swiftindex 79bfe32..3732a0c 100644--- a/Packages/CraCore/Sources/CraCore/Easel.swift+++ b/Packages/CraCore/Sources/CraCore/Easel.swift@@ -17,6 +17,14 @@ public struct Easel: Codable, Equatable, Sendable {(self.id, self.title, self.items) = (id, title, items)}+ /// The address an easel's tab holds: `easel://<id>`. The page area shows the easel there.+ public static let scheme = "easel"+ public var url: String { "\(Self.scheme)://\(id.uuidString)" }+ public static func id(fromURL url: String) -> UUID? {+ guard url.hasPrefix("\(scheme)://") else { return nil }+ return UUID(uuidString: String(url.dropFirst(scheme.count + 3)))+ }+/// The toolbar's tools, in Arc's order (EaselIconPointer … EaselIconFreehand).public enum Tool: String, CaseIterable, Sendable {case pointer, image, text, ellipse, rectangle, arrow, freehanddiff --git a/Packages/CraCore/Tests/CraCoreTests/EaselTests.swift b/Packages/CraCore/Tests/CraCoreTests/EaselTests.swiftindex 25b2840..e7ed274 100644--- a/Packages/CraCore/Tests/CraCoreTests/EaselTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/EaselTests.swift@@ -41,4 +41,10 @@ struct EaselTests {Easel.Item(kind: .image(file: "a.png"), frame: .init(x: 0, y: 0, width: 10, height: 10))]#expect(try JSONDecoder().decode(Easel.self, from: JSONEncoder().encode(e)) == e)}++ @Test func itsTabHoldsItsAddress() {+ let e = Easel()+ #expect(Easel.id(fromURL: e.url) == e.id)+ #expect(Easel.id(fromURL: "https://example.com/") == nil && Easel.id(fromURL: "easel://nope") == nil)+ }}diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex a35e0fe..9925f1e 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -74,6 +74,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {}// Arc's "When opening Arc, restore windows from previous session", off: one window comes back.if !store.settings.restoreWindows { store.keepOnlyActiveWindow() }+ // Before any page is made: an easel's tab opens its canvas.+ EaselBrowser.register()mainWindows = store.prefs.windows.map { MainWindowController(app: self, session: $0) }followKeyWindow()// First launch: the default browser step and the import are the onboarding and@@ -1258,6 +1260,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {store.setExpanded(f.id, true)if isNew { LiveFolderManager.shared.refresh(f.id) }case "newSpace": main.showSpaceEditor(space: nil)+ case "newEasel":+ guard !main.isIncognito else { break }+ let easel = Easel()+ _ = store.createTab(url: easel.url, title: easel.title, select: true, window: main.windowID)case "editSpace": if !main.isStandalone { main.showSpaceEditor(space: store.focusedSpace) }case "changeProfile": if !main.isStandalone { main.showChangeProfileDialog(forSpace: store.focusedSpace.id) }case "deleteSpace": if !main.isStandalone { confirmDeleteSpace(store.focusedSpace) }@@ -1508,7 +1514,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {menubar.addItem(submenu: appMenu, title: "Cra")let file = NSMenu(title: "File")- for id in ["newTab", "newWindow", "newBlankWindow", "newIncognitoWindow", "newLittleWindow", "reopenClosedTab", "editURL", "newFolder", "newSpace"] { file.addItem(item(id)) }+ for id in ["newTab", "newWindow", "newBlankWindow", "newIncognitoWindow", "newLittleWindow", "reopenClosedTab", "editURL", "newFolder", "newSpace", "newEasel"] { file.addItem(item(id)) }file.addItem(.separator())file.addItem(item("closeWindow")); file.addItem(item("closeTab"))file.addItem(.separator())diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swiftindex 5a0b1c2..bbe622e 100644--- a/Sources/Cra/App/KeyBindings.swift+++ b/Sources/Cra/App/KeyBindings.swift@@ -139,6 +139,9 @@ final class KeyBindingRegistry {KeyAction(id: "newGitHubLiveFolder", name: "New GitHub Live Folder", section: .file, shortcuts: [],triggers: ["live folder", "pull requests", "github"]),KeyAction(id: "newSpace", name: "New Space…", section: .file, shortcuts: [], triggers: ["space"]),+ // Arc: File ▸ New Easel ⌃⇧E.+ KeyAction(id: "newEasel", name: "New Easel", section: .file, shortcuts: [Shortcut("e", [.control, .shift])],+ triggers: ["easel", "whiteboard", "canvas", "draw"]),KeyAction(id: "closeWindow", name: "Close Window", section: .file, shortcuts: [Shortcut("w", cmdShift)], inCommandBar: false),KeyAction(id: "closeTab", name: "Close Tab", section: .file, shortcuts: [Shortcut("w", cmd)], triggers: ["close", "archive tab"]),KeyAction(id: "capturePage", name: "Capture…", section: .file, shortcuts: [Shortcut("2", cmdShift)], triggers: ["capture", "screenshot"]),diff --git a/Sources/Cra/Services/WebKit/PageEngines.swift b/Sources/Cra/Services/WebKit/PageEngines.swiftindex 5c775b7..6818dab 100644--- a/Sources/Cra/Services/WebKit/PageEngines.swift+++ b/Sources/Cra/Services/WebKit/PageEngines.swift@@ -3,8 +3,19 @@ import CraCEF/// Which engine draws a page, and the factory every page browser comes from/// (ProtectedMediaSites has the rules; docs/protected-media.md the why).+/// A page Cra draws itself (an Easel) instead of a website. It keeps its own address and hands+/// any other one to the engine that address gets.+@MainActor+protocol NativePage: AnyObject {+ func owns(_ url: String) -> Bool+}+@MainActorenum PageEngines {+ /// The app's pages of its own (EaselBrowser), registered at launch: a browser for an address+ /// one of them owns, else nil.+ static var nativePage: ((_ frame: NSRect, _ url: String, _ delegate: CraBrowserDelegate?, _ incognito: Bool, _ profilePath: String?) -> CraBrowser?)?+/// The list, with the user's own choices (protected-media.json) on it. `defaults write/// dk.kildahl.cra webKitProtectedMedia -bool NO` turns it all off (every page Chromium's again)./// A test instance sets CRA_WEBKIT_DRM=0|1 and CRA_WEBKIT_HOSTS=<host,host> (the scenarios' localhost).@@ -54,6 +65,8 @@ enum PageEngines {/// opener's engine: WebKit can only hand a popup to a web view it made, CEF to a CraBrowser.static func makeBrowser(frame: NSRect, url: String?, delegate: CraBrowserDelegate?, incognito: Bool,profilePath: String?, opener: CraBrowser? = nil) -> CraBrowser {+ // An easel's address (Arc's Easels): its canvas, not a page.+ if let url, let page = nativePage?(frame, url, delegate, incognito, profilePath) { return page }let engine = url.map { sites.engine(for: $0) } ?? opener.map(engine(of:)) ?? .chromiumswitch engine {case .webKit:@@ -69,6 +82,8 @@ enum PageEngines {/// Chromium asks for every main-frame request (CraCEF's OnBeforeBrowse); WebKit only for/// addresses Cra loads (-loadURL:), never for the page's own navigations.static func handoffTarget(from browser: CraBrowser, to url: String, method: String) -> PageEngine? {+ // An easel hands every other address to the engine that address gets.+ if let page = browser as? NativePage { return page.owns(url) ? nil : sites.engine(for: url) }let current = engine(of: browser)switch current {case .chromium: return sites.handoff(from: current, to: url, method: method)diff --git a/Sources/Cra/UI/Easel/EaselBrowser.swift b/Sources/Cra/UI/Easel/EaselBrowser.swiftnew file mode 100644index 0000000..be2267b--- /dev/null+++ b/Sources/Cra/UI/Easel/EaselBrowser.swift@@ -0,0 +1,131 @@+import AppKit+import CraCEF++/// An Easel's page (Arc's File ▸ New Easel ⌃⇧E, measured on Arc 1.172.1; docs/arc-parity.md+/// "Easels, measured"). Like WebKitBrowser it is a CraBrowser hosting its own view in+/// `containerView`, so the tab, split view, the sidebar row and closing work as for any page. The+/// tab's address is `easel://<id>`; the easel itself is `Easels/<id>.json` in the data folder, with+/// its pictures in `Easels/<id>/`.+final class EaselBrowser: CraBrowser, NativePage {+ nonisolated func owns(_ url: String) -> Bool { url == address }++ private let container: NSView+ private let canvas: EaselCanvasView+ private let address: String+ private var closed = false++ override init(frame: NSRect, url: String?, delegate: CraBrowserDelegate?, incognito: Bool, profilePath: String?) {+ container = NSView(frame: frame)+ address = url ?? ""+ let id = url.flatMap(Easel.id(fromURL:)) ?? UUID()+ canvas = MainActor.assumeIsolated { EaselCanvasView(document: EaselFiles.load(id)) }+ super.init()+ self.delegate = delegate+ MainActor.assumeIsolated {+ container.wantsLayer = true+ container.autoresizesSubviews = true+ canvas.frame = container.bounds+ canvas.autoresizingMask = [.width, .height]+ container.addSubview(canvas)+ canvas.onTitle = { [weak self] title in+ guard let self else { return }+ self.delegate?.browser(self, didChangeTitle: title)+ }+ }+ // Like a page, it reports its address and title a turn later, once the tab holds it.+ DispatchQueue.main.async { [weak self] in+ guard let self, !self.closed else { return }+ let title = MainActor.assumeIsolated { self.canvas.document.title }+ self.delegate?.browser(self, didChangeURL: self.address)+ self.delegate?.browser(self, didChangeTitle: title)+ self.delegate?.browser?(self, didChangeCommittedLoad: true)+ self.delegate?.browser(self, didChangeLoading: false, canGoBack: false, canGoForward: false)+ self.delegate?.browser(self, didFinishLoadingURL: self.address, title: title, statusCode: 200)+ }+ }++ override convenience init(frame: NSRect, url: String?, delegate: CraBrowserDelegate?) {+ self.init(frame: frame, url: url, delegate: delegate, incognito: false, profilePath: nil)+ }++ override convenience init(frame: NSRect, url: String?, delegate: CraBrowserDelegate?, incognito: Bool) {+ self.init(frame: frame, url: url, delegate: delegate, incognito: incognito, profilePath: nil)+ }++ override var containerView: NSView { container }+ override var hostWindow: NSWindow? { nil }+ override var currentURL: String { address }+ override var currentTitle: String { MainActor.assumeIsolated { canvas.document.title } }+ override var isLoading: Bool { false }+ override var hasCommittedLoad: Bool { true }+ override var canGoBack: Bool { false }+ override var canGoForward: Bool { false }+ override var isCreated: Bool { !closed }+ override var isClosed: Bool { closed }+ override var hasDevTools: Bool { false }++ /// Another address typed into an easel's tab goes to a page of its own, as the other engine's do.+ override func loadURL(_ url: String) {+ guard url != address else { return }+ _ = delegate?.browser?(self, handsOffNavigationToURL: url, method: "GET")+ }+ override func reload() {}+ override func reloadIgnoringCache() {}+ override func stopLoading() {}+ override func goBack() {}+ override func goForward() {}+ override func setFocused(_ focused: Bool) {+ MainActor.assumeIsolated { if focused { canvas.focus() } }+ }+ override func probeBackgroundColor() {}+ override func executeJavaScript(_ script: String) {}+ override func evaluate(inIsolatedWorld world: String, params: String, completion: @escaping (String?, String?) -> Void) {+ DispatchQueue.main.async { completion(nil, "an Easel has no page") }+ }+ override func sendDevToolsMethod(_ method: String, params: String, completion: @escaping (String?, String?) -> Void) {+ DispatchQueue.main.async { completion(nil, "\(method): an Easel has no page") }+ }+ override func sslStatus() -> CraSSLStatus? { nil }+ override func print() {}+ override func viewSource() {}+ override func notifyMoveOrResizeStarted() {}++ override func close() {+ guard !closed else { return }+ closed = true+ MainActor.assumeIsolated {+ canvas.saveNow()+ canvas.removeFromSuperview()+ }+ DispatchQueue.main.async { [self] in delegate?.browserDidClose(self) }+ }+}++extension EaselBrowser {+ /// PageEngines' hook: an easel's address gets its canvas.+ static func register() {+ PageEngines.nativePage = { frame, url, delegate, incognito, profilePath in+ Easel.id(fromURL: url) == nil ? nil : EaselBrowser(frame: frame, url: url, delegate: delegate, incognito: incognito, profilePath: profilePath)+ }+ }+}++/// Where easels live: one JSON file each, their pictures in a folder of the same name.+@MainActor+enum EaselFiles {+ static var folder: URL {+ let u = AppPaths.supportDir.appendingPathComponent("Easels", isDirectory: true)+ try? FileManager.default.createDirectory(at: u, withIntermediateDirectories: true)+ return u+ }+ static func store(_ id: UUID) -> JSONStore<Easel> {+ _ = folder+ return JSONStore<Easel>("Easels/\(id.uuidString).json")+ }+ static func load(_ id: UUID) -> Easel { store(id).load(or: { Easel(id: id) }) }+ static func pictures(_ id: UUID) -> URL {+ let u = folder.appendingPathComponent(id.uuidString, isDirectory: true)+ try? FileManager.default.createDirectory(at: u, withIntermediateDirectories: true)+ return u+ }+}diff --git a/Sources/Cra/UI/Easel/EaselCanvasView.swift b/Sources/Cra/UI/Easel/EaselCanvasView.swiftnew file mode 100644index 0000000..f60feec--- /dev/null+++ b/Sources/Cra/UI/Easel/EaselCanvasView.swift@@ -0,0 +1,381 @@+import AppKit+import UniformTypeIdentifiers++/// Arc's Easel canvas (Arc 1.172.1, `easelCanvasView`): as wide as the page area and 2436 pt+/// tall, scrolling; the title box 894 pt wide, centred, 52 pt down, bold white; a toolbar at the+/// bottom left, 16 pt in: 36 pt buttons 38 pt apart on the palette's dark backgroundExtra, the+/// picked tool on a lighter fill with 8 pt corners, glyphs in its foreground. Shapes, arrows and+/// strokes are drawn with a drag, text with a click, pictures from a file or the clipboard.+@MainActor+final class EaselCanvasView: NSView {+ private(set) var document: Easel+ var onTitle: (String) -> Void = { _ in }+ private let store: JSONStore<Easel>+ private let scroll = NSScrollView()+ private let sheet: EaselSheetView+ private let toolbar = EaselToolbar()++ init(document: Easel) {+ self.document = document+ store = EaselFiles.store(document.id)+ sheet = EaselSheetView(document: document)+ super.init(frame: .zero)+ wantsLayer = true+ scroll.drawsBackground = false+ scroll.hasVerticalScroller = true+ scroll.autohidesScrollers = true+ scroll.documentView = sheet+ addSubview(scroll)+ addSubview(toolbar)+ sheet.onChange = { [weak self] doc in self?.changed(doc) }+ sheet.onToolDone = { [weak self] in self?.toolbar.tool = .pointer; self?.sheet.tool = .pointer }+ toolbar.onPick = { [weak self] tool in+ guard let self else { return }+ if tool == .image { self.sheet.addPictureFromFile(); return }+ self.sheet.tool = tool+ self.toolbar.tool = tool+ }+ }++ required init?(coder: NSCoder) { fatalError() }++ override var isFlipped: Bool { true }+ override var mouseDownCanMoveWindow: Bool { false }++ private func changed(_ doc: Easel) {+ let renamed = doc.title != document.title+ document = doc+ store.save(doc)+ if renamed { onTitle(doc.title) }+ }++ func saveNow() { store.saveNow(document) }++ func focus() { window?.makeFirstResponder(sheet) }++ override func layout() {+ super.layout()+ scroll.frame = bounds+ sheet.frame = NSRect(x: 0, y: 0, width: max(bounds.width - (scroll.verticalScroller?.frame.width ?? 0) * 0, 300),+ height: Easel.canvasHeight)+ let n = CGFloat(Easel.Tool.allCases.count)+ let w = 4 + n * 38 - 2 + 4+ toolbar.frame = NSRect(x: 16, y: bounds.height - 16 - 44, width: w, height: 44)+ }+}++/// The drawing itself.+@MainActor+final class EaselSheetView: NSView, NSTextFieldDelegate {+ private(set) var document: Easel+ var tool: Easel.Tool = .pointer { didSet { window?.invalidateCursorRects(for: self) } }+ var onChange: (Easel) -> Void = { _ in }+ var onToolDone: () -> Void = {}+ private let title = NSTextField()+ private var texts: [UUID: NSTextField] = [:]+ private var selected: UUID? { didSet { needsDisplay = true } }+ private var dragStart: Easel.Point?+ private var dragLast: Easel.Point?+ private var preview: Easel.Item?+ private var stroke: [Easel.Point] = []+ private var images: [String: NSImage] = [:]++ static let ink = NSColor(white: 1, alpha: 0.92)+ static let selection = NSColor(srgbRed: 0.47, green: 0.71, blue: 0.95, alpha: 1)++ init(document: Easel) {+ self.document = document+ super.init(frame: .zero)+ title.stringValue = document.title+ title.isBordered = false+ title.drawsBackground = false+ title.focusRingType = .none+ title.alignment = .center+ title.font = .systemFont(ofSize: 34, weight: .bold)+ title.textColor = .white+ title.placeholderString = "Untitled Easel"+ title.delegate = self+ addSubview(title)+ for item in document.items { if case .text = item.kind { addTextField(for: item) } }+ registerForDraggedTypes([.fileURL, .png, .tiff])+ }++ required init?(coder: NSCoder) { fatalError() }++ override var isFlipped: Bool { true }+ override var acceptsFirstResponder: Bool { true }+ // The window moves by its background: a drag here draws instead.+ override var mouseDownCanMoveWindow: Bool { false }++ override func layout() {+ super.layout()+ let w = min(CGFloat(Easel.titleWidth), bounds.width - 40)+ title.frame = NSRect(x: (bounds.width - w) / 2, y: CGFloat(Easel.titleTop) + 24, width: w, height: 48)+ for item in document.items { texts[item.id]?.frame = rect(item.frame) }+ }++ private func rect(_ r: Easel.Rect) -> NSRect { NSRect(x: r.x, y: r.y, width: r.width, height: r.height) }+ private func point(_ e: NSEvent) -> Easel.Point { let p = convert(e.locationInWindow, from: nil); return .init(p.x, p.y) }++ private func commit(_ change: (inout Easel) -> Void) {+ change(&document)+ needsDisplay = true+ onChange(document)+ }++ // MARK: Drawing++ override func draw(_ dirtyRect: NSRect) {+ for item in document.items + [preview].compactMap({ $0 }) { draw(item) }+ if stroke.count > 1, let s = Easel.freehand(stroke) { draw(s) }+ if let id = selected, let item = document.items.first(where: { $0.id == id }) {+ let r = rect(item.frame).insetBy(dx: -4, dy: -4)+ Self.selection.setStroke()+ let path = NSBezierPath(roundedRect: r, xRadius: 6, yRadius: 6)+ path.lineWidth = 2+ path.stroke()+ }+ }++ private func draw(_ item: Easel.Item) {+ let color = item.color.flatMap { NSColor(hexString: $0) } ?? Self.ink+ color.setStroke()+ let r = rect(item.frame)+ switch item.kind {+ case .rectangle:+ let p = NSBezierPath(roundedRect: r, xRadius: 4, yRadius: 4); p.lineWidth = 3; p.stroke()+ case .ellipse:+ let p = NSBezierPath(ovalIn: r); p.lineWidth = 3; p.stroke()+ case .arrow(let a, let b):+ let p = NSBezierPath()+ p.move(to: NSPoint(x: a.x, y: a.y)); p.line(to: NSPoint(x: b.x, y: b.y))+ let angle = atan2(b.y - a.y, b.x - a.x), head = 16.0+ for side in [-0.5, 0.5] {+ p.move(to: NSPoint(x: b.x, y: b.y))+ p.line(to: NSPoint(x: b.x - head * cos(angle + side), y: b.y - head * sin(angle + side)))+ }+ p.lineWidth = 3; p.lineCapStyle = .round; p.lineJoinStyle = .round; p.stroke()+ case .freehand(let pts):+ guard let first = pts.first else { return }+ let p = NSBezierPath()+ p.move(to: NSPoint(x: first.x, y: first.y))+ for q in pts.dropFirst() { p.line(to: NSPoint(x: q.x, y: q.y)) }+ p.lineWidth = 3; p.lineCapStyle = .round; p.lineJoinStyle = .round; p.stroke()+ case .image(let file):+ let image = images[file] ?? NSImage(contentsOf: EaselFiles.pictures(document.id).appendingPathComponent(file))+ images[file] = image+ image?.draw(in: r)+ case .text:+ break // a text field of its own+ }+ }++ // MARK: Tools++ override func mouseDown(with event: NSEvent) {+ window?.makeFirstResponder(self)+ let p = point(event)+ dragStart = p+ dragLast = p+ switch tool {+ case .pointer:+ selected = document.item(at: p)?.id+ case .text:+ let item = Easel.Item(kind: .text("", size: 18), frame: .init(x: p.x, y: p.y - 12, width: 240, height: 26))+ commit { $0.items.append(item) }+ addTextField(for: item)+ window?.makeFirstResponder(texts[item.id])+ onToolDone()+ case .freehand:+ stroke = [p]+ default:+ break+ }+ }++ override func mouseDragged(with event: NSEvent) {+ let p = point(event)+ guard let start = dragStart, let last = dragLast else { return }+ dragLast = p+ switch tool {+ case .pointer:+ guard let id = selected, let i = document.items.firstIndex(where: { $0.id == id }) else { return }+ document.items[i] = document.items[i].moved(by: .init(p.x - last.x, p.y - last.y))+ texts[id]?.frame = rect(document.items[i].frame)+ needsDisplay = true+ case .freehand:+ stroke.append(p)+ needsDisplay = true+ default:+ preview = Easel.Item.drawn(tool, from: start, to: p)+ needsDisplay = true+ }+ }++ override func mouseUp(with event: NSEvent) {+ defer { dragStart = nil; dragLast = nil; preview = nil; stroke = [] }+ switch tool {+ case .pointer:+ if selected != nil { onChange(document) }+ case .freehand:+ if stroke.count > 1, let item = Easel.freehand(stroke) { commit { $0.items.append(item) }; selected = nil }+ default:+ if let item = preview, item.frame.width + item.frame.height > 6 {+ commit { $0.items.append(item) }+ selected = item.id+ onToolDone()+ }+ }+ needsDisplay = true+ }++ override func keyDown(with event: NSEvent) {+ if event.keyCode == 51 || event.keyCode == 117, let id = selected { // Delete, Forward Delete+ texts.removeValue(forKey: id)?.removeFromSuperview()+ selected = nil+ commit { $0.items.removeAll { $0.id == id } }+ } else if event.keyCode == 53 {+ selected = nil+ } else {+ super.keyDown(with: event)+ }+ }++ @objc func paste(_ sender: Any?) {+ guard let image = NSImage(pasteboard: .general) else { return }+ addPicture(image, at: nil)+ }++ func addPictureFromFile() {+ guard let window else { return }+ let panel = NSOpenPanel()+ panel.allowedContentTypes = [.image]+ panel.allowsMultipleSelection = true+ panel.beginSheetModal(for: window) { [weak self] response in+ guard response == .OK, let self else { return }+ for url in panel.urls { if let image = NSImage(contentsOf: url) { self.addPicture(image, at: nil) } }+ }+ }++ private func addPicture(_ image: NSImage, at point: NSPoint?) {+ guard let tiff = image.tiffRepresentation, let png = NSBitmapImageRep(data: tiff)?.representation(using: .png, properties: [:]) else { return }+ let name = UUID().uuidString + ".png"+ try? png.write(to: EaselFiles.pictures(document.id).appendingPathComponent(name))+ let scale = min(1, 420 / max(image.size.width, image.size.height, 1))+ let size = NSSize(width: image.size.width * scale, height: image.size.height * scale)+ let visible = enclosingScrollView?.documentVisibleRect ?? bounds+ let center = point ?? NSPoint(x: visible.midX, y: visible.midY)+ let item = Easel.Item(kind: .image(file: name), frame: .init(x: center.x - size.width / 2, y: center.y - size.height / 2,+ width: size.width, height: size.height))+ images[name] = image+ commit { $0.items.append(item) }+ selected = item.id+ }++ // Pictures and image files dropped on the canvas.+ override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation { .copy }+ override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {+ let at = convert(sender.draggingLocation, from: nil)+ let urls = sender.draggingPasteboard.readObjects(forClasses: [NSURL.self], options: [.urlReadingContentsConformToTypes: [UTType.image.identifier]]) as? [URL] ?? []+ let pictures = urls.compactMap(NSImage.init(contentsOf:)) + (urls.isEmpty ? [NSImage(pasteboard: sender.draggingPasteboard)].compactMap { $0 } : [])+ for image in pictures { addPicture(image, at: at) }+ return !pictures.isEmpty+ }++ // MARK: Text++ private func addTextField(for item: Easel.Item) {+ guard case .text(let string, let size) = item.kind else { return }+ let f = NSTextField(string: string)+ f.isBordered = false+ f.drawsBackground = false+ f.focusRingType = .none+ f.font = .systemFont(ofSize: size, weight: .medium)+ f.textColor = .white+ f.placeholderString = "Type something"+ f.delegate = self+ f.identifier = NSUserInterfaceItemIdentifier(item.id.uuidString)+ f.frame = rect(item.frame)+ addSubview(f)+ texts[item.id] = f+ }++ func controlTextDidChange(_ obj: Notification) {+ guard let f = obj.object as? NSTextField else { return }+ if f === title {+ commit { $0.title = f.stringValue.isEmpty ? "Untitled Easel" : f.stringValue }+ return+ }+ guard let id = f.identifier.flatMap({ UUID(uuidString: $0.rawValue) }),+ let i = document.items.firstIndex(where: { $0.id == id }), case .text(_, let size) = document.items[i].kind else { return }+ let width = max(240, ceil(f.intrinsicContentSize.width) + 8)+ commit {+ $0.items[i].kind = .text(f.stringValue, size: size)+ $0.items[i].frame.width = width+ }+ f.frame.size.width = width+ }++ override func resetCursorRects() {+ addCursorRect(bounds, cursor: tool == .pointer ? .arrow : (tool == .text ? .iBeam : .crosshair))+ }+}++/// Arc's Easel toolbar: Pointer, Image, Text, Ellipse, Rectangle, Arrow, Freehand.+@MainActor+final class EaselToolbar: NSView {+ var onPick: (Easel.Tool) -> Void = { _ in }+ var tool: Easel.Tool = .pointer { didSet { needsDisplay = true } }++ private static let symbols: [Easel.Tool: String] = [+ .pointer: "cursorarrow", .image: "photo", .text: "character", .ellipse: "circle",+ .rectangle: "square", .arrow: "arrow.up.right", .freehand: "scribble",+ ]+ private static let names: [Easel.Tool: String] = [+ .pointer: "Select", .image: "Image", .text: "Text", .ellipse: "Ellipse", .rectangle: "Rectangle", .arrow: "Arrow", .freehand: "Draw",+ ]+ // Measured on a gold space: bar #100D00 (backgroundExtra), picked #716328, glyphs #FAEEC2.+ private static let bar = NSColor(srgbRed: 0.06, green: 0.05, blue: 0.0, alpha: 0.96)+ private static let picked = NSColor(white: 1, alpha: 0.22)+ private static let glyph = NSColor(white: 1, alpha: 0.92)++ override var isFlipped: Bool { true }++ override var mouseDownCanMoveWindow: Bool { false }++ private func buttonRect(_ i: Int) -> NSRect { NSRect(x: 4 + CGFloat(i) * 38, y: 4, width: 36, height: 36) }++ override func draw(_ dirtyRect: NSRect) {+ Self.bar.setFill()+ NSBezierPath(roundedRect: bounds, xRadius: 12, yRadius: 12).fill()+ for (i, t) in Easel.Tool.allCases.enumerated() {+ let r = buttonRect(i)+ if t == tool {+ Self.picked.setFill()+ NSBezierPath(roundedRect: r, xRadius: 8, yRadius: 8).fill()+ }+ let config = NSImage.SymbolConfiguration(pointSize: 17, weight: .semibold).applying(.init(paletteColors: [Self.glyph]))+ guard let img = NSImage(systemSymbolName: Self.symbols[t] ?? "circle", accessibilityDescription: Self.names[t])?+ .withSymbolConfiguration(config) else { continue }+ img.draw(in: NSRect(x: r.midX - img.size.width / 2, y: r.midY - img.size.height / 2, width: img.size.width, height: img.size.height))+ }+ }++ override func mouseDown(with event: NSEvent) {+ let p = convert(event.locationInWindow, from: nil)+ for (i, t) in Easel.Tool.allCases.enumerated() where buttonRect(i).contains(p) { onPick(t) }+ }++ override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }++ override func isAccessibilityElement() -> Bool { true }+ override func accessibilityRole() -> NSAccessibility.Role? { .toolbar }+ override func accessibilityLabel() -> String? { "Easel tools" }+}++private extension NSColor {+ convenience init?(hexString: String) {+ guard let c = HexColor.components(hexString) else { return nil }+ self.init(srgbRed: c.r, green: c.g, blue: c.b, alpha: 1)+ }+}diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swiftindex f6b394d..5edd92e 100644--- a/Sources/Cra/UI/PaneToolbarView.swift+++ b/Sources/Cra/UI/PaneToolbarView.swift@@ -169,6 +169,8 @@ final class PaneToolbarView: NSView {m.host = AppSettings.siteKey(for: t.url) ?? human// Arc shows the host only unless "Show Full URL" is on (#88).m.path = store.settings.toolbarShowsFullURL && human.hasPrefix(m.host) ? String(human.dropFirst(m.host.count)) : ""+ // An easel's bar shows its name (Arc 1.172.1).+ if Easel.id(fromURL: t.url) != nil { m.host = item.displayTitle; m.path = "" }}m.protectedMedia = m.tabID.flatMap { ui.navState(for: $0).protectedMedia }let extensions = ExtensionStore.shareddiff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swiftindex c10b91f..2df4465 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift@@ -286,7 +286,9 @@ final class SpaceListView: NSView, NSDraggingSource {} else if let tab = item.tab {let selected = store.isSelected(item.id, window: window)let navigatedAway = pinned && tab.url != tab.savedURL && !tab.savedURL.isEmpty- let (img, flip) = icon(tab.iconKey)+ // An easel's row has an easel glyph, not a favicon (Arc's EaselCellView).+ let (img, flip) = Easel.id(fromURL: tab.url) != nil && tab.customIconKey == nil+ ? (NSImage(systemSymbolName: "pencil.and.scribble", accessibilityDescription: "Easel"), false) : icon(tab.iconKey)let (homeImg, homeFlip) = navigatedAway ? icon(tab.customIconKey ?? FaviconKey.key(for: tab.savedURL)) : (img, flip)let developerMode = store.settings.isDeveloperMode(url: tab.url)// Tidy Tab Titles' rename: "Double-click to rename" under the new name for a few seconds.diff --git a/Tests/Scenarios/easel.scenario b/Tests/Scenarios/easel.scenarionew file mode 100644index 0000000..e0f09c5--- /dev/null+++ b/Tests/Scenarios/easel.scenario@@ -0,0 +1,11 @@+# Arc's File ▸ New Easel (⌃⇧E, Arc 1.172.1, docs/arc-parity.md "Easels, measured"): a Today tab on an+# easel:// address whose page is Cra's canvas, not a web page; it comes back after a relaunch.+budget rss=700 stalls50=10+cra://action/newEasel+wait 2+cra://debug?browserWindows=created+expect-log Cra browser windows created: kind=normal .*tabs=\[easel://[0-9A-F-]{36}\] open=easel://[0-9A-F-]{36} page=1+relaunch+wait 4+cra://debug?browserWindows=relaunched+expect-log browser windows relaunched: kind=normal listed=1 tabs=1 open=1diff --git a/docs/arc-parity.md b/docs/arc-parity.mdindex a8cc158..a27e3b2 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 | missing | Measured below; not built. |+| 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). || 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 ↗". |@@ -123,6 +123,9 @@ in this sweep (Essential Shortcuts window, Library pages).measured live in Arc (names, #RRGGBBAA format, no trace in the page's markup) and fitted to thesemantic palette Arc stores per space.- 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).## Easels, measured (Arc 1.172.1, offline copy, 7 Nov 2026)@@ -142,7 +145,6 @@ in this sweep (Essential Shortcuts window, Library pages).- Boosts: the offline Arc has no network and a local server is blocked in this session, so its Boosteditor couldn't be put on screen to copy. Needs a site in Arc (Victor's OK to run the real Arc, ora localhost server).-- Easels and Notes: whole document types with their own editors; same approach once Boosts is in.- AppleScript dictionary (a new way for other apps to drive Cra; worth a decision on what it may do,as for cra:// URLs), cookie banner blocking, window dragging from the top of pages (measured, above), Previews andJoin Meeting: not started.