oficina / docs Public

Docs native S2a: the Mac document window — one title, subtitle, header, floating Format

Spec 2026-11-22-native-redesign-design.md §1, §6, §8; plan S2a.

- One title: the window's title stays the document's (.navigationTitle) and
  the system no longer draws it (.toolbar(removing: .title)); Docs' title
  area at the toolbar's leading edge draws it in 15pt semibold with the §6
  subtitle under it. The .principal item that drew it twice is gone.
  Rename in place uses an AppKit field: SwiftUI focus does not reach a
  toolbar item's hosting view, so a TextField there appeared without the
  keyboard and never saw Esc.
- Subtitle (DocsSubtitle.swift): every §6 row from one pure function, the
  1 s "Saving…" debounce in a .task, the kit's announcement rule plus No
  longer available and a mid-session View only. Its own view, so a sync
  status change no longer re-evaluates the body hosting the text view.
- Header controls: the undo/redo pill, the Format toggle (a Toggle, so
  VoiceOver says toggle button) and Share…, three toolbar items so a narrow
  window overflows Share… first. Readers get none of them.
- The floating Format inspector (Paul's ruling 1, option B): 248pt glass
  panel over the desk with the web's Style, Text, Alignment and Lists
  sections; open by default and app-wide (docs.inspector.open); never
  shown to a reader. Replaces the formatting strip and the inspector column
  on the Mac (iOS keeps both until S3).
- Page centring by translation: the scroll view's document view is a
  DocsDeskView holding the page, a fixed 612pt paper band, at the web's
  clamp; toggling the inspector or resizing moves one frame origin.
- refreshAccess: 403/404 is "No longer available" (left again on a 200,
  with retry()); a 401 pauses input without touching can_write, and the
  re-minted session's stream resumes it; a 200 without can_write is View
  only in place.
- Menus: View ▸ Show/Hide Format ⌥⌘I, Paged/Infinite, Zoom; Format on the
  web's keys with Headings 1–3; Tools ▸ Word count; Help ▸ Keyboard
  shortcuts; File ▸ Open a document… ⌘K as a sheet that opens or focuses
  the result's window.
- Strings: the §8 keys this slice uses in all twelve languages (the new
  English awaiting copy review); Mac.strings keys left without a reader
  deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 8d5ace328dff3b5b5f900e9124a3d381ac9ab7f7 parent d5a328a
41 files changed, +1,337 −350
  • native/apple/Sources/DocsApp/DocsAccountWindow.swift +5 −1
  • native/apple/Sources/DocsApp/DocsDocumentWindow.swift +6 −1
  • native/apple/Sources/DocsApp/DocsWindowCommands.swift +1 −0
  • native/apple/Sources/DocsApp/DocsWindows.swift +3 −0
  • native/apple/Sources/DocsKit/DocsDesk.swift +134 −0
  • native/apple/Sources/DocsKit/DocsDocumentHeader.swift +280 −0
  • native/apple/Sources/DocsKit/DocsDocumentMenu.swift +21 −5
  • native/apple/Sources/DocsKit/DocsEditorCommands.swift +62 −27
  • native/apple/Sources/DocsKit/DocsEditorContext.swift +5 −1
  • native/apple/Sources/DocsKit/DocsFormatInspector.swift +225 −0
  • native/apple/Sources/DocsKit/DocsJumpControls.swift +7 −0
  • native/apple/Sources/DocsKit/DocsModel.swift +37 −3
  • native/apple/Sources/DocsKit/DocsPagedTextView.swift +3 −1
  • native/apple/Sources/DocsKit/DocsSubtitle.swift +188 −0
  • native/apple/Sources/DocsKit/DocsToolsControls.swift +54 −38
  • native/apple/Sources/DocsKit/DocsWorkspace.swift +83 −30
  • native/apple/Sources/DocsKit/NativeDocumentTextView.swift +7 −3
  • native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/ar.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/bn.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/en.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/es.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/ga.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/hi.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/ja.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/pt.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/ru.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/vi.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/yue.lproj/Mac.strings +0 −20
  • native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings +18 −0
  • native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Mac.strings +0 −20
diff --git a/native/apple/Sources/DocsApp/DocsAccountWindow.swift b/native/apple/Sources/DocsApp/DocsAccountWindow.swift
index f0d45b5..4560b4e 100644
--- a/native/apple/Sources/DocsApp/DocsAccountWindow.swift
+++ b/native/apple/Sources/DocsApp/DocsAccountWindow.swift
@@ -171,7 +171,10 @@ struct DocsAccountWindow: View {
windows.updateRecents(documents, account: account, client: client)
})
.id(account)
- .onAppear { windows.transports[account] = oficina.transport(for: account) }
+ .onAppear {
+ windows.transports[account] = oficina.transport(for: account)
+ windows.teamNames[account] = state.team.name
+ }
.safeAreaInset(edge: .bottom, spacing: 0) { passkeyNudge }
.sheet(isPresented: $pickingTeam) { teamPicker(state) }
#else
@@ -304,6 +307,7 @@ struct DocsAccountWindow: View {
windows.updateRecents(documents, account: account, client: client)
})
.id(account)
+ .onAppear { windows.teamNames[account] = connection.accounts.first { $0.id == account }?.name }
}
#else
DocsWorkspace(client: client, accountID: connection.activeAccountID, transport: transport(for: connection.activeAccountID), accounts: connection.showAccounts, signOut: connection.signOut)
diff --git a/native/apple/Sources/DocsApp/DocsDocumentWindow.swift b/native/apple/Sources/DocsApp/DocsDocumentWindow.swift
index b5ce9e2..a7c1152 100644
--- a/native/apple/Sources/DocsApp/DocsDocumentWindow.swift
+++ b/native/apple/Sources/DocsApp/DocsDocumentWindow.swift
@@ -8,7 +8,12 @@ struct DocsDocumentWindow: View {
@Environment(\.openWindow) private var openWindow
var body: some View {
if let entry = windows.entries.first(where: { $0.id == id }) {
- DocsWorkspace(client: entry.client, accountID: entry.account, transport: windows.transports[entry.account], signOut: {}, documentID: entry.document, newDocument: entry.isDraft, documentChanged: { document, title in windows.attach(entry.id, document: document, title: title) })
+ DocsWorkspace(client: entry.client, accountID: entry.account, transport: windows.transports[entry.account], signOut: {}, documentID: entry.document, newDocument: entry.isDraft, documentChanged: { document, title in windows.attach(entry.id, document: document, title: title) },
+ openDocument: { document, title in
+ // Open a document… (⌘K) opens or focuses that document's window.
+ let id = windows.reserve(account: entry.account, document: document, title: title, client: entry.client)
+ openWindow(id: "document", value: id)
+ }, team: windows.teamNames[entry.account])
.id(entry.id)
.focusedSceneValue(\.docsWindowAccount, entry.account)
.onAppear { windows.setOpen(entry.id, true) }
diff --git a/native/apple/Sources/DocsApp/DocsWindowCommands.swift b/native/apple/Sources/DocsApp/DocsWindowCommands.swift
index 70a1197..c70c2d1 100644
--- a/native/apple/Sources/DocsApp/DocsWindowCommands.swift
+++ b/native/apple/Sources/DocsApp/DocsWindowCommands.swift
@@ -40,6 +40,7 @@ struct DocsWindowCommands: Commands {
openWindow(id: "home")
}
}.keyboardShortcut("n")
+ DocsOpenDocumentMenuItem()
Menu(docsMacString("Recent")) {
ForEach(windows.entries.filter { $0.account == (account ?? windows.activeAccount) }.prefix(20)) { entry in
Button(entry.title) {
diff --git a/native/apple/Sources/DocsApp/DocsWindows.swift b/native/apple/Sources/DocsApp/DocsWindows.swift
index 4a004f8..f533120 100644
--- a/native/apple/Sources/DocsApp/DocsWindows.swift
+++ b/native/apple/Sources/DocsApp/DocsWindows.swift
@@ -31,6 +31,9 @@ import SwiftUI
/// rather than the one it opened with. Server accounts have none: their
/// windows keep the client they were opened with, as before.
var transports: [String: @MainActor () -> NativeTransport?] = [:]
+ /// Each account's team name, for a document window's subtitle (spec
+ /// D7): the Oficina ID team's name, or the server account's.
+ var teamNames: [String: String] = [:]
func reserve(account: String, document: String, title: String, client: NativeHTTP) -> UUID {
if let index = entries.firstIndex(where: { $0.account == account && $0.client.origin == client.origin && $0.document == document }) {
var entry = entries.remove(at: index)
diff --git a/native/apple/Sources/DocsKit/DocsDesk.swift b/native/apple/Sources/DocsKit/DocsDesk.swift
new file mode 100644
index 0000000..7a83e0e
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsDesk.swift
@@ -0,0 +1,134 @@
+import Foundation
+#if os(macOS)
+import AppKit
+#endif
+
+/// Where the page sits on the desk, the web's `show.html` rule in window
+/// points (spec §1, "Page centring"). Pure arithmetic, so the six widths and
+/// the 1,108pt boundary are a unit test.
+///
+/// The trailing desk padding is `E = clamp(16, 16 + P + 2R − W, R)`, where
+/// `R` is the floating inspector's reserve (248 + 12 + 16) and `P` the page's
+/// width in window points; the page is centred in the band `[16, W − E]`.
+/// When the band is narrower than the page its leading edge stays at 16 and
+/// it runs under the inspector: the page never shrinks or reflows.
+struct DocsDeskLayout: Equatable, Sendable {
+ static let padding: CGFloat = 16
+ static let inspectorWidth: CGFloat = 248
+ /// The inspector's gap from the toolbar and from the window's edge.
+ static let inspectorInset: CGFloat = 12
+ static var reserve: CGFloat { inspectorWidth + inspectorInset + padding }
+ /// The paper's width in its own (unmagnified) points.
+ static let paperWidth: CGFloat = 612
+
+ /// Which side the inspector floats on, nil while it is hidden. It is the
+ /// trailing side: the right, or the left in a right-to-left language.
+ enum Side: Equatable, Sendable { case right, left }
+
+ /// `E`, the padding on the inspector's side.
+ static func inspectorPadding(width: CGFloat, page: CGFloat, inspector: Bool) -> CGFloat {
+ guard inspector else { return padding }
+ return min(max(padding, padding + page + 2 * reserve - width), reserve)
+ }
+
+ /// The page's distance from the inspector-free (leading) edge.
+ static func leadingEdge(width: CGFloat, page: CGFloat, inspector: Bool) -> CGFloat {
+ let band = width - padding - inspectorPadding(width: width, page: page, inspector: inspector)
+ return padding + max(0, (band - page) / 2)
+ }
+
+ /// The page's left edge in window points, for either side.
+ static func pageX(width: CGFloat, page: CGFloat, inspector side: Side?) -> CGFloat {
+ let leading = leadingEdge(width: width, page: page, inspector: side != nil)
+ guard side == .left else { return leading }
+ // Mirrored: the leading edge is the right. A page wider than the
+ // window still starts at the left padding and scrolls to the right.
+ return max(padding, width - leading - page)
+ }
+}
+
+#if os(macOS)
+/// The scroll view's document view: it draws the desk and holds the page
+/// (`DocsPagedTextView`, a fixed paper band) as its only subview, at
+/// `x = pageX / m`. Toggling the inspector or resizing the window moves that
+/// one frame origin, so the page slides and the text never reflows
+/// (spec §1, "Moving the page never relayouts the text").
+@MainActor final class DocsDeskView: NSView {
+ let page: NSView
+ var inspector: DocsDeskLayout.Side? {
+ didSet { if oldValue != inspector { arrange() } }
+ }
+ private var observers: [NSObjectProtocol] = []
+
+ init(page: NSView) {
+ self.page = page
+ super.init(frame: page.frame)
+ autoresizingMask = [.width]
+ page.autoresizingMask = []
+ addSubview(page)
+ page.postsFrameChangedNotifications = true
+ observers.append(NotificationCenter.default.addObserver(forName: NSView.frameDidChangeNotification, object: page, queue: nil) { [weak self] _ in
+ MainActor.assumeIsolated { self?.arrange() }
+ })
+ }
+ required init?(coder: NSCoder) { fatalError("init(coder:) is unavailable") }
+ isolated deinit { observers.forEach(NotificationCenter.default.removeObserver) }
+
+ override var isFlipped: Bool { true }
+ override var isOpaque: Bool { true }
+
+ override func viewDidMoveToSuperview() {
+ super.viewDidMoveToSuperview()
+ guard let clip = superview as? NSClipView else { return }
+ clip.postsBoundsChangedNotifications = true
+ clip.postsFrameChangedNotifications = true
+ for name in [NSView.boundsDidChangeNotification, NSView.frameDidChangeNotification] {
+ observers.append(NotificationCenter.default.addObserver(forName: name, object: clip, queue: nil) { [weak self] _ in
+ MainActor.assumeIsolated { self?.arrange() }
+ })
+ }
+ arrange()
+ }
+
+ /// The scroll view's magnification: document units to window points.
+ private var magnification: CGFloat { enclosingScrollView?.magnification ?? 1 }
+
+ /// Sets the page's origin and the desk's size from the rule. O(1).
+ func arrange() {
+ guard let clip = superview as? NSClipView else { return }
+ let m = magnification
+ let width = clip.bounds.width * m
+ let pageWidth = page.frame.width * m
+ let x = DocsDeskLayout.pageX(width: width, page: pageWidth, inspector: inspector) / m
+ let origin = CGPoint(x: x, y: 0)
+ if page.frame.origin != origin { page.setFrameOrigin(origin) }
+ let size = CGSize(width: max(clip.bounds.width, x + page.frame.width + DocsDeskLayout.padding / m), height: page.frame.height)
+ if abs(frame.width - size.width) > 0.01 || abs(frame.height - size.height) > 0.01 { setFrameSize(size) }
+ }
+
+ override func resize(withOldSuperviewSize oldSize: NSSize) {
+ super.resize(withOldSuperviewSize: oldSize)
+ arrange()
+ }
+
+ override func draw(_ dirtyRect: NSRect) {
+ NSColor.windowBackgroundColor.setFill()
+ dirtyRect.fill()
+ }
+
+ /// A click on the desk beside the page goes to the page, as it did when
+ /// the text view spanned the window.
+ override func mouseDown(with event: NSEvent) { page.mouseDown(with: event) }
+}
+#endif
+
+#if os(macOS)
+extension NativeDocumentTextView {
+ /// The side the floating inspector covers, for the desk's centring.
+ func inspectorSide(_ side: DocsDeskLayout.Side?) -> NativeDocumentTextView {
+ var view = self
+ view.inspector = side
+ return view
+ }
+}
+#endif
diff --git a/native/apple/Sources/DocsKit/DocsDocumentHeader.swift b/native/apple/Sources/DocsKit/DocsDocumentHeader.swift
new file mode 100644
index 0000000..ffd0386
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsDocumentHeader.swift
@@ -0,0 +1,280 @@
+#if os(macOS)
+import AppKit
+import RastrilloApple
+import SwiftUI
+
+/// The app-wide Format inspector state (spec D1): open by default, one value
+/// for every window, remembered across launches.
+enum DocsInspectorState {
+ static let key = "docs.inspector.open"
+ static let defaultOpen = true
+}
+
+/// Docs' own title area at the toolbar's leading edge (spec §1, header
+/// contract): the document's title in 15pt semibold, and under it the §6
+/// subtitle. The system title is hidden but still set, so the Window menu,
+/// Mission Control, window tabs and VoiceOver's window name are the title.
+///
+/// Its own view, reading the model's title, access and sync status itself,
+/// so none of those re-evaluates the body that hosts the text view.
+@MainActor struct DocsTitleArea: View {
+ let model: DocsModel
+ let team: String?
+ @Binding var renaming: Bool
+ let beginRename: () -> Void
+ let finishRename: () -> Void
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 1) {
+ title
+ DocsSubtitleView(model: model, team: team)
+ }
+ .frame(minWidth: 120, maxWidth: 520, alignment: .leading)
+ .fixedSize(horizontal: false, vertical: true)
+ .accessibilityElement(children: .contain)
+ .accessibilityIdentifier("docs.document.header")
+ }
+
+ /// Esc: the title as it was.
+ private func cancelRename() { model.renameInput = nil; renaming = false }
+
+ @ViewBuilder private var title: some View {
+ if renaming {
+ // An AppKit field: SwiftUI's focus does not reach into a toolbar
+ // item's hosting view, so a TextField there appears without the
+ // keyboard and never sees Esc. This one takes focus as it
+ // appears, commits on Return or focus loss, and reverts on Esc.
+ DocsRenameField(text: model.renameInput ?? model.detail?.title ?? "",
+ placeholder: String(localized: "docs.list.create.placeholder", bundle: DocsResources.bundle),
+ changed: { model.renameInput = $0 }, commit: finishRename, cancel: cancelRename)
+ .frame(minWidth: 180, maxWidth: 480)
+ } else {
+ let canWrite = model.detail?.can_write == true
+ Text(verbatim: model.detail?.title ?? " ")
+ .font(.system(size: 15, weight: .semibold))
+ .foregroundStyle(OficinaPalette.text)
+ .lineLimit(1).truncationMode(.tail)
+ .accessibilityAddTraits(.isHeader)
+ .accessibilityIdentifier("docs.document.title")
+ .onTapGesture(count: 2) { if canWrite { beginRename() } }
+ .contextMenu {
+ if canWrite {
+ Button { beginRename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) }
+ .keyboardShortcut("r", modifiers: [.command, .shift])
+ }
+ }
+ .accessibilityActions {
+ if canWrite {
+ Button { beginRename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) }
+ }
+ }
+ }
+ }
+}
+
+/// The header's trailing controls, 8pt apart (spec §1): the undo/redo pill
+/// and the Format toggle for writers, then Share… for owners and members.
+/// A reader gets none of them.
+@MainActor struct DocsHeaderControls: View {
+ enum Part { case history, format, share }
+ let model: DocsModel
+ @Binding var inspectorOpen: Bool
+ var part: Part
+ let share: () -> Void
+
+ var body: some View {
+ let canWrite = model.access == .writable
+ let canShare = model.detail?.can_share == true && !model.isDraft && model.access != .unavailable
+ switch part {
+ case .history:
+ if canWrite { DocsUndoRedoPill(model: model).fixedSize() }
+ case .format:
+ if canWrite {
+ Toggle(isOn: $inspectorOpen) {
+ Label { Text("docs.editor.inspector.toggle", bundle: DocsResources.bundle) } icon: { Image(systemName: "pencil") }
+ }
+ .toggleStyle(.button)
+ .buttonStyle(DocsPillStyle(kind: inspectorOpen ? .toggledOn : .quiet))
+ .help(Text(inspectorOpen ? "native.format.hide" : "native.format.show", bundle: DocsResources.bundle))
+ .accessibilityIdentifier("docs.format.toggle")
+ }
+ case .share:
+ if canShare {
+ Button(action: share) { Text("docs.share.action", bundle: DocsResources.bundle) }
+ .buttonStyle(DocsPillStyle(kind: .filled))
+ .accessibilityIdentifier("docs.share")
+ }
+ }
+ }
+}
+
+/// Undo and redo in one pill, a hairline between them, each enabled from
+/// the projection's `canUndo`/`canRedo` (spec §1, item 1).
+@MainActor struct DocsUndoRedoPill: View {
+ let model: DocsModel
+ var body: some View {
+ let projection = model.projection
+ HStack(spacing: 0) {
+ button("docs.editor.toolbar.undo", icon: "arrow.uturn.backward", op: "undo", enabled: projection?.canUndo == true)
+ Rectangle().fill(OficinaPalette.line).frame(width: 1, height: 14)
+ button("docs.editor.toolbar.redo", icon: "arrow.uturn.forward", op: "redo", enabled: projection?.canRedo == true)
+ }
+ .background(Capsule().fill(OficinaPalette.sunk))
+ .overlay(Capsule().stroke(OficinaPalette.line, lineWidth: 1))
+ .accessibilityElement(children: .contain)
+ .accessibilityLabel(Text("docs.editor.toolbar.history", bundle: DocsResources.bundle))
+ }
+ private func button(_ key: String, icon: String, op: String, enabled: Bool) -> some View {
+ Button {
+ // Undo needs no rendered content: only the model's own check.
+ DocumentCommands(model: model, content: NSAttributedString()).perform(op)
+ } label: {
+ Image(systemName: icon)
+ .font(.system(size: 13, weight: .semibold))
+ .flipsForRightToLeftLayoutDirection(true)
+ .frame(width: 30, height: 28)
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .foregroundStyle(OficinaPalette.text)
+ .opacity(enabled ? 1 : 0.35)
+ .disabled(!enabled)
+ .help(Text(LocalizedStringKey(key), bundle: DocsResources.bundle))
+ .accessibilityLabel(Text(LocalizedStringKey(key), bundle: DocsResources.bundle))
+ .accessibilityIdentifier("docs." + op)
+ }
+}
+
+/// The header's pills (the web's I2 header): quiet, toggled on (accent-soft
+/// with accent text) and the one filled accent pill. 28pt tall; they grow
+/// with their label rather than truncate it (spec §9, long languages).
+struct DocsPillStyle: ButtonStyle {
+ enum Kind { case quiet, toggledOn, filled }
+ let kind: Kind
+ @Environment(\.isEnabled) private var isEnabled
+ func makeBody(configuration: Configuration) -> some View {
+ let accent = OficinaPalette.accent(.docs)
+ configuration.label
+ .labelStyle(.titleAndIcon)
+ .font(.system(size: 13, weight: .semibold))
+ .lineLimit(1)
+ .fixedSize()
+ .padding(.horizontal, 14)
+ .frame(height: 28)
+ .foregroundStyle(kind == .filled ? OficinaPalette.onAccent : kind == .toggledOn ? accent : OficinaPalette.text)
+ .background {
+ switch kind {
+ case .filled: Capsule().fill(accent)
+ case .toggledOn: Capsule().fill(OficinaPalette.accentSoft(.docs)).overlay(Capsule().stroke(accent.opacity(0.3), lineWidth: 1))
+ case .quiet: Capsule().fill(OficinaPalette.sunk).overlay(Capsule().stroke(OficinaPalette.line, lineWidth: 1))
+ }
+ }
+ .opacity(configuration.isPressed ? 0.8 : isEnabled ? 1 : 0.5)
+ .contentShape(Capsule())
+ }
+}
+#endif
+
+#if os(macOS)
+/// The window's callouts under the header (spec §6, banners): No longer
+/// available (row 1) with Close and, with changes unsent, Discard changes;
+/// and today's `errorKey` text with Try again and Discard changes. Their own
+/// view, so the text view's host does not read either.
+@MainActor struct DocsDocumentCallouts: View {
+ let model: DocsModel
+ let discard: () -> Void
+ let close: () -> Void
+ var body: some View {
+ VStack(spacing: 8) {
+ if model.access == .unavailable {
+ callout(Text("native.unavailable.body", bundle: DocsResources.bundle), negative: true) {
+ Button { close() } label: { Text("native.close", bundle: DocsResources.bundle) }
+ if model.hasUnsavedChanges {
+ Button(role: .destructive) { discard() } label: { Text("native.discard.action", bundle: DocsResources.bundle) }
+ }
+ }
+ } else if let key = model.errorKey {
+ callout(Text(LocalizedStringKey(key), bundle: DocsResources.bundle), negative: false) {
+ Button { Task { await model.retry() } } label: { Text("native.retry", bundle: DocsResources.bundle) }
+ if model.hasUnsavedChanges {
+ Button(role: .destructive) { discard() } label: { Text("native.discard.action", bundle: DocsResources.bundle) }
+ }
+ }
+ }
+ }
+ .padding(.top, 12)
+ .frame(maxWidth: 560)
+ }
+ private func callout<Actions: View>(_ text: Text, negative: Bool, @ViewBuilder actions: () -> Actions) -> some View {
+ HStack(spacing: 12) {
+ text.font(.callout).foregroundStyle(negative ? OficinaPalette.negative : OficinaPalette.text)
+ .fixedSize(horizontal: false, vertical: true)
+ Spacer(minLength: 8)
+ actions().controlSize(.small)
+ }
+ .padding(.horizontal, 14).padding(.vertical, 10)
+ .background(RoundedRectangle(cornerRadius: 10).fill(negative ? OficinaPalette.negativeSoft : OficinaPalette.surface))
+ .overlay(RoundedRectangle(cornerRadius: 10).strokeBorder(OficinaPalette.line, lineWidth: 1))
+ .shadow(color: .black.opacity(0.08), radius: 8, y: 3)
+ .accessibilityElement(children: .contain)
+ .accessibilityIdentifier(negative ? "docs.callout.unavailable" : "docs.callout.error")
+ }
+}
+#endif
+
+#if os(macOS)
+/// The title's rename field (spec §1, "Rename in place"): Return or focus
+/// loss commits through `model.commitRename()`, Esc reverts.
+struct DocsRenameField: NSViewRepresentable {
+ let text: String
+ let placeholder: String
+ let changed: (String) -> Void
+ let commit: () -> Void
+ let cancel: () -> Void
+ func makeCoordinator() -> Coordinator { Coordinator(self) }
+ func makeNSView(context: Context) -> NSTextField {
+ let field = FocusingField(string: text)
+ field.placeholderString = placeholder
+ field.isBordered = false
+ field.drawsBackground = false
+ field.focusRingType = .none
+ field.font = .systemFont(ofSize: 15, weight: .semibold)
+ field.lineBreakMode = .byTruncatingTail
+ field.cell?.isScrollable = true
+ field.delegate = context.coordinator
+ field.setAccessibilityIdentifier("docs.document.title")
+ return field
+ }
+ func updateNSView(_ field: NSTextField, context: Context) { context.coordinator.parent = self }
+ @MainActor final class Coordinator: NSObject, NSTextFieldDelegate {
+ var parent: DocsRenameField
+ private var done = false
+ init(_ parent: DocsRenameField) { self.parent = parent }
+ func controlTextDidChange(_ note: Notification) {
+ if let field = note.object as? NSTextField { parent.changed(field.stringValue) }
+ }
+ func control(_ control: NSControl, textView: NSTextView, doCommandBy selector: Selector) -> Bool {
+ if selector == #selector(NSResponder.cancelOperation(_:)) { done = true; parent.cancel(); return true }
+ if selector == #selector(NSResponder.insertNewline(_:)) { parent.commit(); return true }
+ return false
+ }
+ func controlTextDidEndEditing(_ note: Notification) {
+ guard !done else { return }
+ done = true
+ parent.commit()
+ }
+ }
+ /// Takes the keyboard as soon as it is in a window, with the title selected.
+ final class FocusingField: NSTextField {
+ override func viewDidMoveToWindow() {
+ super.viewDidMoveToWindow()
+ guard let window else { return }
+ DispatchQueue.main.async { [weak self] in
+ guard let self, self.window === window else { return }
+ window.makeFirstResponder(self)
+ self.currentEditor()?.selectAll(nil)
+ }
+ }
+ }
+}
+#endif
diff --git a/native/apple/Sources/DocsKit/DocsDocumentMenu.swift b/native/apple/Sources/DocsKit/DocsDocumentMenu.swift
index 728a9b8..d024f14 100644
--- a/native/apple/Sources/DocsKit/DocsDocumentMenu.swift
+++ b/native/apple/Sources/DocsKit/DocsDocumentMenu.swift
@@ -1,22 +1,38 @@
#if os(macOS)
import SwiftUI
+/// File ▸ Open a document… (⌘K): the jump palette as a sheet over the
+/// focused document window, or over the home window (spec §1, menus).
+public struct DocsOpenDocumentMenuItem: View {
+ @FocusedValue(\.docsJump) private var jump
+ public init() {}
+ public var body: some View {
+ Button { jump?.wrappedValue = true } label: { Text("docs.editor.menu.file.open", bundle: DocsResources.bundle) }
+ .keyboardShortcut("k")
+ .disabled(jump == nil)
+ }
+}
+extension FocusedValues { @Entry var docsJump: Binding<Bool>? }
+
public struct DocsDocumentMenu: View {
@FocusedValue(\.docsEditor) private var editor
public init() {}
public var body: some View {
Group {
- Button { editor?.rename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) }
- .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.detail?.can_write != true)
+ // Absent, not disabled, for a reader (spec §1, reader mode).
+ if editor == nil || editor?.model.access == .writable {
+ Button { editor?.rename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) }
+ .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.access != .writable)
+ }
Button(docsMacString("Save")) { if let editor { Task { _ = await editor.model.saveAll() } } }
.keyboardShortcut("s").disabled(editor == nil)
Menu(docsMacString("Export")) {
Button(docsMacString("PDF…")) { editor?.exportRequest.wrappedValue = "pdf" }
Button(docsMacString("Markdown…")) { editor?.exportRequest.wrappedValue = "markdown" }
}.disabled(editor == nil || editor?.model.isDraft == true)
- Button(docsMacString("Share…")) {
- if let editor { Task { if await editor.model.saveAll() { editor.sharing.wrappedValue = true } } }
- }.disabled(editor?.model.detail?.can_share != true)
+ Button { if let editor { Task { if await editor.model.saveAll() { editor.sharing.wrappedValue = true } } } } label: {
+ Text("docs.share.action", bundle: DocsResources.bundle)
+ }.disabled(editor?.model.detail?.can_share != true || editor?.model.isDraft == true || editor?.model.access == .unavailable)
Divider()
diff --git a/native/apple/Sources/DocsKit/DocsEditorCommands.swift b/native/apple/Sources/DocsKit/DocsEditorCommands.swift
index 77a1c83..418e73b 100644
--- a/native/apple/Sources/DocsKit/DocsEditorCommands.swift
+++ b/native/apple/Sources/DocsKit/DocsEditorCommands.swift
@@ -2,58 +2,93 @@
import AppKit
import SwiftUI
+/// The Mac's Format, View and Tools menus (spec §1, "Menus and shortcuts"),
+/// labelled with the web's keys where one exists.
public struct DocsEditorCommands: Commands {
@FocusedValue(\.docsEditor) private var editor
+ /// The floating inspector's app-wide state (spec D1): ⌥⌘I flips it for
+ /// every window at once.
+ @AppStorage(DocsInspectorState.key) private var inspectorOpen = DocsInspectorState.defaultOpen
public init() {}
+
+ private static let sizes = [8, 9, 10, 11, 12, 14, 18, 24, 36, 48, 72]
+ private func text(_ key: String) -> Text { Text(LocalizedStringKey(key), bundle: DocsResources.bundle) }
+
public var body: some Commands {
CommandGroup(replacing: .printItem) {}
- CommandMenu(docsMacString("Format")) {
+ CommandMenu(text("docs.editor.menu.format")) {
Group {
- Button(docsMacString("Bold")) { editor?.actions?.perform("bold") }.keyboardShortcut("b")
- Button(docsMacString("Italic")) { editor?.actions?.perform("italic") }.keyboardShortcut("i")
- Button(docsMacString("Inline code")) { editor?.actions?.perform("code") }
- Menu(docsMacString("Paragraph style")) {
- Button(docsMacString("Normal")) { editor?.actions?.block("paragraph") }
- ForEach(1...6, id: \.self) { level in
- Button(String(format: docsMacString("Heading %d"), level)) { editor?.actions?.block("heading", level: level) }
+ Button { editor?.actions?.perform("bold") } label: { text("docs.editor.toolbar.bold") }.keyboardShortcut("b")
+ Button { editor?.actions?.perform("italic") } label: { text("docs.editor.toolbar.italic") }.keyboardShortcut("i")
+ Button { editor?.actions?.perform("code") } label: { text("docs.editor.toolbar.code") }
+ Divider()
+ // Body text and Heading 1–3, as the web: Headings 4–6 still
+ // render and edit, but are not offered.
+ Menu {
+ Button { editor?.actions?.block("paragraph") } label: { text("docs.editor.toolbar.block.paragraph") }
+ ForEach(1...3, id: \.self) { level in
+ Button { editor?.actions?.block("heading", level: level) } label: { text(EditorToolbar.headingKey(level)) }
}
- Button(docsMacString("Bullet list")) { editor?.actions?.block("bullet_list") }
- Button(docsMacString("Numbered list")) { editor?.actions?.block("ordered_list") }
- Button(docsMacString("Block quote")) { editor?.actions?.block("blockquote") }
- }
- Menu(docsMacString("Font")) {
+ } label: { text("docs.editor.toolbar.block") }
+ Button { editor?.actions?.block("bullet_list") } label: { text("docs.editor.toolbar.bulletlist") }
+ Button { editor?.actions?.block("ordered_list") } label: { text("docs.editor.toolbar.orderedlist") }
+ Button { editor?.actions?.block("blockquote") } label: { text("docs.editor.toolbar.quote") }
+ Divider()
+ Menu {
// Each family's name in its own face; SwiftUI carries the
// font into the menu item's attributed title.
ForEach(DocsFontPicker.entries) { entry in
Button { editor?.actions?.setFont(entry.key) } label: { DocsFontPicker.label(entry) }
}
- }
- Menu(docsMacString("Size")) {
- ForEach([8, 9, 10, 11, 12, 14, 18, 24, 36, 48, 72], id: \.self) { size in
- Button(size.formatted()) { editor?.actions?.format("size_\(size)", exclusive: [8,9,10,11,12,14,18,24,36,48,72].map { "size_\($0)" } + ["size_sm", "size_lg", "size_xl"]) }
+ } label: { text("docs.editor.toolbar.font") }
+ Menu {
+ ForEach(Self.sizes, id: \.self) { size in
+ Button(size.formatted()) { editor?.actions?.format("size_" + String(size), exclusive: Self.sizes.map { "size_" + String($0) } + ["size_sm", "size_lg", "size_xl"]) }
}
+ } label: { text("docs.editor.toolbar.size") }
+ Divider()
+ ForEach(["left", "center", "right"], id: \.self) { value in
+ Button { editor?.actions?.blockAttribute("align", value: value == "left" ? nil : value) } label: { text("docs.editor.toolbar.align." + value) }
}
- Menu(docsMacString("Alignment")) {
- ForEach(["left", "center", "right"], id: \.self) { value in
- Button(String(localized: String.LocalizationValue("docs.editor.toolbar.align." + value), bundle: DocsResources.bundle)) { editor?.actions?.blockAttribute("align", value: value == "left" ? nil : value) }
- }
- }
- Button(docsMacString("Indent")) { editor?.actions?.perform("indent") }
- Button(docsMacString("Outdent")) { editor?.actions?.perform("outdent") }
- Button(docsMacString("Clear formatting")) { editor?.actions?.perform("clear-format") }
+ Divider()
+ Button { editor?.actions?.perform("indent") } label: { text("docs.editor.menu.format.indent") }
+ Button { editor?.actions?.perform("outdent") } label: { text("docs.editor.menu.format.outdent") }
+ Button { editor?.actions?.perform("clear-format") } label: { text("docs.editor.menu.format.clear") }
}.disabled(editor?.actions?.isEnabled != true || !(NSApp.keyWindow?.firstResponder is DocsTextView))
}
CommandGroup(after: .toolbar) {
+ // Disabled in a reader's window and in the home window (no
+ // editor), where there is no inspector to show.
+ Button { inspectorOpen.toggle() } label: { text(inspectorOpen ? "native.format.hide" : "native.format.show") }
+ .keyboardShortcut("i", modifiers: [.command, .option])
+ .disabled(editor?.model.access != .writable)
+ Divider()
+ if let editor {
+ Picker(selection: editor.paged) {
+ text("docs.editor.menu.view.paged").tag(true)
+ text("docs.editor.menu.view.infinite").tag(false)
+ } label: { EmptyView() }
+ .pickerStyle(.inline)
+ }
+ Divider()
+ // Native only: the web has no zoom.
Menu(docsMacString("Zoom")) {
ForEach([0.5, 0.75, 1.0, 1.25, 1.5, 2.0], id: \.self) { value in
Button { editor?.zoom.wrappedValue = value } label: { Text(value, format: .percent) }
}
}.disabled(editor == nil)
Button(docsMacString("Actual size")) { editor?.zoom.wrappedValue = 1 }.keyboardShortcut("0").disabled(editor == nil)
- Button(docsMacString("Document inspector")) { editor?.inspecting.wrappedValue.toggle() }.disabled(editor == nil)
- if let editor { Toggle(docsMacString("Pages"), isOn: editor.paged) }
+ }
+ // Help: Keyboard shortcuts…, then the Colophon (DocsWindowCommands).
+ CommandGroup(before: .help) {
+ Button { editor?.shortcuts.wrappedValue = true } label: { text("docs.editor.menu.tools.shortcuts") }
+ .disabled(editor == nil)
+ }
+ CommandMenu(text("docs.editor.menu.tools")) {
+ Button { editor?.wordCount.wrappedValue = true } label: { text("docs.editor.menu.tools.wordcount") }
+ .disabled(editor?.model.projection == nil)
}
}
}
diff --git a/native/apple/Sources/DocsKit/DocsEditorContext.swift b/native/apple/Sources/DocsKit/DocsEditorContext.swift
index f604c9f..dfe4289 100644
--- a/native/apple/Sources/DocsKit/DocsEditorContext.swift
+++ b/native/apple/Sources/DocsKit/DocsEditorContext.swift
@@ -9,9 +9,13 @@ struct DocsEditorContext {
let client: NativeTransport
let zoom: Binding<Double>
let paged: Binding<Bool>
- let inspecting: Binding<Bool>
let sharing: Binding<Bool>
let exportRequest: Binding<String?>
+ /// Open a document… (⌘K): the jump sheet over this window.
+ let jumping: Binding<Bool>
+ /// Tools ▸ Word count… and Help ▸ Keyboard shortcuts…, as sheets.
+ let wordCount: Binding<Bool>
+ let shortcuts: Binding<Bool>
@MainActor var actions: DocumentCommands? {
guard NSApp.keyWindow?.firstResponder is DocsTextView, let projection = model.projection else { return nil }
return DocumentCommands(model: model, content: NativeTextProjection.render(projection))
diff --git a/native/apple/Sources/DocsKit/DocsFormatInspector.swift b/native/apple/Sources/DocsKit/DocsFormatInspector.swift
new file mode 100644
index 0000000..d3aa0d3
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsFormatInspector.swift
@@ -0,0 +1,225 @@
+#if os(macOS)
+import AppKit
+import RastrilloApple
+import SwiftUI
+
+/// The floating Format inspector (Paul's ruling 1, option B; spec §1): a
+/// 248pt glass panel over the desk, 12pt below the toolbar and 12pt from the
+/// trailing edge, with the web inspector's four sections. An overlay in the
+/// editor's ZStack, never SwiftUI's `.inspector` (a closed `.inspector`
+/// invalidates hosting constraints on macOS 27 while the editor loads).
+///
+/// Its controls act on the text view's selection: buttons and pop-ups on the
+/// Mac do not take first responder from a click, so the caret stays where
+/// it was. Selected states come from `DocumentToolbarSelection`, as the
+/// menus' do. It reads the selection itself, so moving the caret
+/// re-evaluates this and not the body hosting the text view.
+@MainActor struct DocsFormatInspector: View {
+ let model: DocsModel
+ let content: NSAttributedString
+ @State private var settledSelection = DocumentToolbarSelection()
+ @Environment(\.accessibilityReduceTransparency) private var reduceTransparency
+ @Environment(\.colorScheme) private var colorScheme
+ @Environment(\.locale) private var locale
+
+ static let sizes = [8, 9, 10, 11, 12, 14, 18, 24, 36, 48, 72]
+
+ private var actions: DocumentCommands { DocumentCommands(model: model, content: content) }
+ private var currentSelection: DocumentToolbarSelection? { DocumentToolbarSelection(commands: actions) }
+
+ var body: some View {
+ let actions = self.actions
+ let selection = currentSelection ?? settledSelection
+ VStack(alignment: .leading, spacing: 14) {
+ section("docs.editor.toolbar.group.style") {
+ stylePicker(selection)
+ HStack(spacing: 6) {
+ DocsFontPopUp(selected: selection.font) { actions.setFont($0) }
+ .frame(maxWidth: .infinity)
+ sizePicker(selection).frame(width: 64)
+ }
+ }
+ section("docs.editor.toolbar.group.text") {
+ DocsSegmentedRow(items: [
+ .init(key: "docs.editor.toolbar.bold", icon: "bold", on: selection.marks.contains("strong")) { actions.perform("bold") },
+ .init(key: "docs.editor.toolbar.italic", icon: "italic", on: selection.marks.contains("em")) { actions.perform("italic") },
+ .init(key: "docs.editor.toolbar.code", icon: "chevron.left.forwardslash.chevron.right", on: selection.marks.contains("code")) { actions.perform("code") },
+ ])
+ }
+ section("docs.editor.toolbar.group.align") {
+ DocsSegmentedRow(items: ["left", "center", "right"].map { value in
+ .init(key: "docs.editor.toolbar.align." + value, icon: "text.align" + value, on: selection.alignment == value) {
+ actions.blockAttribute("align", value: value == "left" ? nil : value)
+ }
+ })
+ }
+ section("docs.editor.toolbar.group.lists") {
+ DocsSegmentedRow(items: [
+ .init(key: "docs.editor.toolbar.bulletlist", icon: "list.bullet", on: selection.blocks.contains("bullet_list")) { actions.block("bullet_list") },
+ .init(key: "docs.editor.toolbar.orderedlist", icon: "list.number", on: selection.blocks.contains("ordered_list")) { actions.block("ordered_list") },
+ .init(key: "docs.editor.toolbar.quote", icon: "text.quote", on: selection.blocks.contains("blockquote")) { actions.block("blockquote") },
+ ])
+ // Native keeps the mock-up's second row (spec §13 Q2).
+ DocsSegmentedRow(items: [
+ .init(key: "docs.editor.menu.format.outdent", icon: "decrease.indent", on: false, mirrors: true) { actions.perform("outdent") },
+ .init(key: "docs.editor.menu.format.indent", icon: "increase.indent", on: false, mirrors: true) { actions.perform("indent") },
+ .init(key: "docs.editor.menu.format.clear", icon: "eraser", on: false, enabled: selection.hasSelection) { actions.perform("clear-format") },
+ ])
+ }
+ }
+ .padding(12)
+ .frame(width: DocsDeskLayout.inspectorWidth, alignment: .leading)
+ .background { panel }
+ .overlay {
+ // A hairline accent rim: accent mixed into the line colour, 70% in
+ // light, 30% in dark. Kept under Increase Contrast.
+ RoundedRectangle(cornerRadius: 12)
+ .strokeBorder(OficinaPalette.accent(.docs).mix(with: OficinaPalette.line, by: colorScheme == .dark ? 0.7 : 0.3), lineWidth: 1)
+ }
+ .compositingGroup()
+ .shadow(color: .black.opacity(colorScheme == .dark ? 0.4 : 0.14), radius: 16, y: 6)
+ // Replica work briefly gates commands on every keystroke; keep that
+ // out of the disabled styling so the panel does not blink.
+ .disabled(!actions.isAvailable)
+ .allowsHitTesting(actions.isEnabled)
+ .accessibilityElement(children: .contain)
+ .accessibilityLabel(Text("docs.editor.inspector.label", bundle: DocsResources.bundle))
+ .accessibilityIdentifier("docs.format.inspector")
+ .onChange(of: currentSelection, initial: true) { _, value in
+ if let value { settledSelection = value }
+ }
+ }
+
+ @ViewBuilder private var panel: some View {
+ if reduceTransparency {
+ RoundedRectangle(cornerRadius: 12).fill(OficinaPalette.surface)
+ } else {
+ RoundedRectangle(cornerRadius: 12).fill(.clear).glassEffect(.regular, in: RoundedRectangle(cornerRadius: 12))
+ }
+ }
+
+ private func section<Content: View>(_ key: String, @ViewBuilder content: () -> Content) -> some View {
+ VStack(alignment: .leading, spacing: 6) {
+ Text(LocalizedStringKey(key), bundle: DocsResources.bundle)
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(OficinaPalette.textMuted)
+ .fixedSize(horizontal: false, vertical: true)
+ .accessibilityAddTraits(.isHeader)
+ content()
+ }
+ .accessibilityElement(children: .contain)
+ .accessibilityLabel(Text(LocalizedStringKey(key), bundle: DocsResources.bundle))
+ }
+
+ /// Body text and Heading 1–3, each in its own face.
+ private func stylePicker(_ selection: DocumentToolbarSelection) -> some View {
+ let strings = DocsStrings(locale: locale)
+ var entries = [DocsPopUp.Entry(id: "paragraph", title: strings("docs.editor.toolbar.block.paragraph"),
+ font: DocsFonts.font(marks: [:], size: 13, heading: false))]
+ for level in 1...3 {
+ entries.append(.init(id: "heading" + String(level), title: strings(EditorToolbar.headingKey(level)),
+ font: DocsFonts.font(marks: [:], size: [18, 16, 14][level - 1], heading: true)))
+ }
+ return DocsPopUp(entries: entries, selected: selection.style, label: strings("docs.editor.toolbar.block"), identifier: "docs.style-picker") { style in
+ if style.hasPrefix("heading"), let level = Int(style.dropFirst("heading".count)) { actions.block("heading", level: level) }
+ else { actions.block("paragraph") }
+ }
+ .frame(maxWidth: .infinity)
+ }
+
+ private func sizePicker(_ selection: DocumentToolbarSelection) -> some View {
+ let strings = DocsStrings(locale: locale)
+ return DocsPopUp(entries: Self.sizes.map { .init(id: String($0), title: $0.formatted(.number.locale(locale)), font: nil) },
+ selected: String(selection.size), label: strings("docs.editor.toolbar.size"), identifier: "docs.size-picker") { size in
+ actions.format("size_" + size, exclusive: Self.sizes.map { "size_" + String($0) } + ["size_sm", "size_lg", "size_xl"])
+ }
+ }
+}
+
+/// A Mac pop-up button over fixed entries, each title in its own face when
+/// it has one, as `DocsFontPopUp` draws the families. It stretches to the
+/// width it is given.
+struct DocsPopUp: NSViewRepresentable {
+ struct Entry { let id: String; let title: String; let font: NSFont? }
+ let entries: [Entry]
+ let selected: String
+ let label: String
+ let identifier: String
+ let choose: (String) -> Void
+ func makeCoordinator() -> Coordinator { Coordinator() }
+ func makeNSView(context: Context) -> NSPopUpButton {
+ let button = NSPopUpButton(frame: .zero, pullsDown: false)
+ button.target = context.coordinator
+ button.action = #selector(Coordinator.picked(_:))
+ button.setContentHuggingPriority(.defaultLow, for: .horizontal)
+ button.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
+ button.setAccessibilityIdentifier(identifier)
+ return button
+ }
+ func updateNSView(_ button: NSPopUpButton, context: Context) {
+ context.coordinator.choose = choose
+ button.isEnabled = context.environment.isEnabled
+ button.setAccessibilityLabel(label)
+ let titles = entries.map(\.title)
+ if button.itemArray.map(\.title) != titles {
+ let menu = NSMenu()
+ for entry in entries {
+ let item = NSMenuItem(title: entry.title, action: nil, keyEquivalent: "")
+ item.representedObject = entry.id
+ if let font = entry.font { item.attributedTitle = NSAttributedString(string: entry.title, attributes: [.font: font]) }
+ menu.addItem(item)
+ }
+ button.menu = menu
+ }
+ if let index = entries.firstIndex(where: { $0.id == selected }), button.indexOfSelectedItem != index { button.selectItem(at: index) }
+ }
+ @MainActor final class Coordinator: NSObject {
+ var choose: (String) -> Void = { _ in }
+ @objc func picked(_ sender: NSPopUpButton) {
+ if let id = sender.selectedItem?.representedObject as? String { choose(id) }
+ }
+ }
+}
+
+/// Joined 28pt buttons in one well; a lit one is accent-soft with an accent
+/// glyph, and says so to VoiceOver (`.isSelected`), never by colour alone.
+struct DocsSegmentedRow: View {
+ struct Item: Identifiable {
+ let key: String
+ let icon: String
+ let on: Bool
+ var enabled = true
+ /// Indent and outdent point along the line: they mirror right to left.
+ var mirrors = false
+ let action: () -> Void
+ var id: String { key }
+ }
+ let items: [Item]
+ var body: some View {
+ let accent = OficinaPalette.accent(.docs)
+ HStack(spacing: 2) {
+ ForEach(items) { item in
+ Button(action: item.action) {
+ Image(systemName: item.icon)
+ .font(.system(size: 13, weight: .medium))
+ .flipsForRightToLeftLayoutDirection(item.mirrors)
+ .frame(maxWidth: .infinity, minHeight: 24)
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .foregroundStyle(item.on ? accent : OficinaPalette.text)
+ .background(RoundedRectangle(cornerRadius: 6).fill(item.on ? OficinaPalette.accentSoft(.docs) : .clear))
+ .overlay(RoundedRectangle(cornerRadius: 6).strokeBorder(item.on ? accent.opacity(0.55) : .clear, lineWidth: 1))
+ .disabled(!item.enabled)
+ .opacity(item.enabled ? 1 : 0.4)
+ .help(Text(LocalizedStringKey(item.key), bundle: DocsResources.bundle))
+ .accessibilityLabel(Text(LocalizedStringKey(item.key), bundle: DocsResources.bundle))
+ .accessibilityAddTraits(item.on ? .isSelected : [])
+ }
+ }
+ .padding(2)
+ .frame(height: 28)
+ .background(RoundedRectangle(cornerRadius: 8).fill(OficinaPalette.sunk))
+ }
+}
+#endif
diff --git a/native/apple/Sources/DocsKit/DocsJumpControls.swift b/native/apple/Sources/DocsKit/DocsJumpControls.swift
index 561d2c9..60e9eaa 100644
--- a/native/apple/Sources/DocsKit/DocsJumpControls.swift
+++ b/native/apple/Sources/DocsKit/DocsJumpControls.swift
@@ -27,6 +27,8 @@ private struct DocumentSearchResult: Decodable, Identifiable {
@MainActor struct DocsJumpSheet: View {
let model: DocsModel
let client: NativeTransport
+ /// The Mac opens or focuses the result's own window; nil opens it here.
+ var openElsewhere: ((String, String) -> Void)? = nil
@Environment(\.dismiss) private var dismiss
@FocusState private var searchFocused: Bool
@State private var query = ""
@@ -117,6 +119,11 @@ private struct DocumentSearchResult: Decodable, Identifiable {
}
private func open(_ result: DocumentSearchResult) {
guard !working, query == resultsQuery, let sqid = result.sqid else { return }
+ if let openElsewhere {
+ openElsewhere(sqid, result.title)
+ dismiss()
+ return
+ }
working = true
Task {
defer { working = false }
diff --git a/native/apple/Sources/DocsKit/DocsModel.swift b/native/apple/Sources/DocsKit/DocsModel.swift
index e7228a7..41427f0 100644
--- a/native/apple/Sources/DocsKit/DocsModel.swift
+++ b/native/apple/Sources/DocsKit/DocsModel.swift
@@ -16,6 +16,13 @@ import RastrilloNative
var renderedGeneration: UInt64 = 0
var composing = false
var inputPaused = false
+ /// Spec §6 row 1: a 403 or 404 said the document was deleted or is no
+ /// longer shared. Left again on a later 200.
+ var unavailable = false
+ /// Input paused by a 401 while the session is re-minted (§6 notes).
+ @ObservationIgnored private var pausedForSession = false
+ /// What the window may do with the document (§6 rows 1 and 10).
+ var access: DocsAccess { unavailable ? .unavailable : detail?.can_write == true ? .writable : .readOnly }
var explicitCommandRevision: UInt64 = 0
var loading = false
var creatingDocument = false
@@ -272,6 +279,8 @@ import RastrilloNative
let epoch = UUID(); documentEpoch = epoch; editorIdentity = UUID()
streamTask?.cancel(); streamTask = nil
let previous = replica; replica = nil; detail = nil; projection = nil
+ if unavailable { unavailable = false }
+ pausedForSession = false
loading = true; errorKey = nil
if let previous { await previous.close() }
guard documentEpoch == epoch else { return }
@@ -485,7 +494,11 @@ import RastrilloNative
while !Task.isCancelled, documentEpoch == epoch, detail?.sqid == sqid {
await flush()
do {
- try await client().stream("/d/\(sqid)/stream", onOpen: { await reconnect.opened() }) { [weak self] line in
+ try await client().stream("/d/\(sqid)/stream", onOpen: { [weak self] in
+ await reconnect.opened()
+ // A stream opening again after a 401 is the re-minted session.
+ await self?.sessionReopened(sqid, epoch: epoch)
+ }) { [weak self] line in
if line.hasPrefix("data:"), let seq = Int64(line.dropFirst(5).trimmingCharacters(in: .whitespaces)) {
await self?.refresh(sqid, remoteSequence: seq)
}
@@ -657,6 +670,9 @@ import RastrilloNative
guard streamTask == nil, replica != nil, !isDraft, let sqid = detail?.sqid else { return }
streamTask = Task { [weak self] in await self?.listen(sqid) }
}
+ private func sessionReopened(_ sqid: String, epoch: UUID) async {
+ if pausedForSession { await refreshAccess(sqid, epoch: epoch) }
+ }
/// Revalidate capability after stream/write rejection while retaining the draft.
private func refreshAccess(_ sqid: String, epoch: UUID) async {
let revision = titleRevision
@@ -671,9 +687,27 @@ import RastrilloNative
let title = pendingTitle ?? ((hadPendingTitle || titleRevision != revision) ? (detail?.title ?? current.title) : current.title)
detail = DocumentDetail(sqid: current.sqid, title: title, guid: current.guid, can_write: current.can_write, can_share: current.can_share)
if !current.can_write { inputPaused = true }
- } else if [401, 403, 404].contains(reply.status) {
+ // Spec §6: a 200 after row 1 (re-shared or restored) leaves it,
+ // and releases the entries held meanwhile; after a 401, the
+ // re-minted session's 200 resumes input with the access as is.
+ if unavailable {
+ unavailable = false
+ if current.can_write { Task { [weak self] in await self?.retry() } }
+ }
+ if pausedForSession {
+ pausedForSession = false
+ if current.can_write, localFailure == nil, laneSummary.held == 0, inputPaused { inputPaused = false }
+ }
+ } else if reply.status == 401 {
+ // The session ended, not the access: pause input and leave
+ // can_write and the chrome alone while the session is re-minted.
+ pausedForSession = true
+ if !inputPaused { inputPaused = true }
+ } else if [403, 404].contains(reply.status) {
+ // Deleted, or no longer shared: row 1, "No longer available".
+ if !unavailable { unavailable = true }
inputPaused = true
- if let current = detail {
+ if let current = detail, current.can_write || current.can_share {
detail = DocumentDetail(sqid: current.sqid, title: current.title, guid: current.guid, can_write: false, can_share: false)
}
}
diff --git a/native/apple/Sources/DocsKit/DocsPagedTextView.swift b/native/apple/Sources/DocsKit/DocsPagedTextView.swift
index 3ed20fc..73d33fd 100644
--- a/native/apple/Sources/DocsKit/DocsPagedTextView.swift
+++ b/native/apple/Sources/DocsKit/DocsPagedTextView.swift
@@ -47,7 +47,9 @@ import AppKit
layoutSubtreeIfNeeded()
super.didChangeText()
}
- private var viewportWidth: CGFloat { max(636, enclosingScrollView?.contentView.bounds.width ?? bounds.width) }
+ /// A fixed paper band: the desk (DocsDeskView) places and centres it, so
+ /// a width change or the inspector never changes the text's geometry.
+ private var viewportWidth: CGFloat { DocsDeskLayout.paperWidth }
private func updatePagination() {
guard !updatingPagination else { return }
updatingPagination = true
diff --git a/native/apple/Sources/DocsKit/DocsSubtitle.swift b/native/apple/Sources/DocsKit/DocsSubtitle.swift
new file mode 100644
index 0000000..3b70b67
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsSubtitle.swift
@@ -0,0 +1,188 @@
+import Foundation
+import RastrilloApple
+import RastrilloNative
+import SwiftUI
+
+/// What the window can do with its document, from the last detail answer
+/// (spec §6 rows 1 and 10). A 401 is not here: it pauses input and leaves
+/// the access alone while the session is re-minted.
+enum DocsAccess: Equatable, Sendable {
+ case writable
+ case readOnly
+ /// A 403 or 404 from `refreshAccess`: deleted, or no longer shared.
+ case unavailable
+}
+
+/// One row of spec §6's subtitle table, in its precedence order. The first
+/// that applies wins (`init(...)`).
+enum DocsSubtitleRow: Equatable, Sendable {
+ case unavailable // 1
+ case failedHeld // 2
+ case cannotSaveOnDevice // 3
+ case tooManyUnsent // 4
+ case needsSignIn(pending: Int) // 5
+ case signedOut // 6
+ case offline(pending: Int) // 7, and 12 is `saved` with the banner
+ case retrying(pending: Int) // 8
+ case saving // 9
+ case viewOnly // 10
+ case saved // 11 and 12
+ case loading // 13
+
+ /// - `savingShown`: the status has not been `.saved` for a whole second
+ /// (the debounce, kept by the view in a `.task`, never in `body`).
+ /// - `loading`: no projection yet.
+ ///
+ /// Row 13 is checked before rows 10 and 11: the table lists it last, but
+ /// a document still loading is "saved" to the outbox, so taken in the
+ /// table's order it could never show.
+ init(access: DocsAccess, status: SyncStatus, savingShown: Bool, loading: Bool) {
+ if access == .unavailable { self = .unavailable; return }
+ switch status {
+ case .failed(_, .held): self = .failedHeld; return
+ case .failed(_, .cannotSaveOnDevice): self = .cannotSaveOnDevice; return
+ case .failed(_, .tooManyUnsent): self = .tooManyUnsent; return
+ case .needsSignIn(let pending): self = pending > 0 ? .needsSignIn(pending: pending) : .signedOut; return
+ case .offline(let pending): self = .offline(pending: pending); return
+ case .retrying(let pending): self = .retrying(pending: pending); return
+ case .saving, .saved: break
+ }
+ if savingShown { self = .saving; return }
+ if loading { self = .loading; return }
+ self = access == .readOnly ? .viewOnly : .saved
+ }
+
+ /// Red, and the words say what went wrong (rows 1–6).
+ var isNegative: Bool {
+ switch self {
+ case .unavailable, .failedHeld, .cannotSaveOnDevice, .tooManyUnsent, .needsSignIn, .signedOut: return true
+ default: return false
+ }
+ }
+ /// Only row 2 is semibold, as the kit's failed status is.
+ var isEmphasised: Bool { self == .failedHeld }
+
+ /// The kit's rule (offline, needs sign-in and failed are announced, a
+ /// count change inside one kind is not, saving never is), plus No longer
+ /// available, and View only when it arrives mid-session.
+ static func announces(from old: DocsSubtitleRow, to new: DocsSubtitleRow) -> Bool {
+ if sameKind(old, new) { return false }
+ switch new {
+ case .unavailable, .failedHeld, .cannotSaveOnDevice, .tooManyUnsent, .needsSignIn, .signedOut, .offline: return true
+ case .viewOnly: return old != .loading
+ default: return false
+ }
+ }
+ static func sameKind(_ a: DocsSubtitleRow, _ b: DocsSubtitleRow) -> Bool {
+ switch (a, b) {
+ case (.offline, .offline), (.retrying, .retrying): return true
+ case (.needsSignIn, .needsSignIn), (.needsSignIn, .signedOut), (.signedOut, .needsSignIn), (.signedOut, .signedOut): return true
+ default: return a == b
+ }
+ }
+}
+
+/// Docs' catalog read in one localisation, so a view drawn in Arabic for a
+/// snapshot says Arabic even though the process runs in English, and the
+/// kit's sync wording in the same language.
+struct DocsStrings {
+ let bundle: Bundle
+ let localization: String
+
+ init(locale: Locale) {
+ let available = DocsResources.bundle.localizations.filter { $0 != "Base" }
+ let chosen = Bundle.preferredLocalizations(from: available, forPreferences: [locale.identifier]).first
+ ?? DocsResources.bundle.preferredLocalizations.first ?? "en"
+ localization = chosen
+ bundle = DocsResources.bundle.path(forResource: chosen, ofType: "lproj").flatMap(Bundle.init(path:)) ?? DocsResources.bundle
+ }
+ func callAsFunction(_ key: String) -> String { bundle.localizedString(forKey: key, value: nil, table: nil) }
+ var sync: NativeSyncStrings { NativeSyncStrings.kit(localization: localization) }
+
+ /// `native.subtitle.joined` ("%1$@ · %2$@"), looked up as a key and then
+ /// formatted, so a right-to-left language can order the two.
+ func joined(_ first: String?, _ second: String?) -> String {
+ switch (first?.isEmpty == false ? first : nil, second) {
+ case (let first?, let second?): return String(format: self("native.subtitle.joined"), first, second)
+ case (let first?, nil): return first
+ case (nil, let second?): return second
+ case (nil, nil): return ""
+ }
+ }
+
+ /// The state half of the subtitle, nil when the row says only the team.
+ func state(_ row: DocsSubtitleRow) -> String? {
+ let sync = self.sync
+ switch row {
+ case .unavailable: return self("native.subtitle.unavailable")
+ case .failedHeld: return sync.failed(.held(.tooLarge))
+ case .cannotSaveOnDevice: return sync.failed(.cannotSaveOnDevice)
+ case .tooManyUnsent: return sync.failed(.tooManyUnsent)
+ case .needsSignIn(let pending): return sync.needsSignIn(pending)
+ case .signedOut: return self("native.subtitle.signedOut")
+ case .offline(let pending): return sync.offline(pending)
+ case .retrying: return sync.retrying
+ case .saving: return sync.saving
+ case .viewOnly: return self("native.subtitle.viewOnly")
+ case .saved: return self("native.subtitle.saved")
+ case .loading: return nil
+ }
+ }
+ func subtitle(team: String?, row: DocsSubtitleRow) -> String { joined(team, state(row)) }
+}
+
+/// The subtitle under the document's title: "<Team> · <state>" (spec §6).
+/// Its own small view, so a sync status change re-evaluates this and
+/// nothing else: the body that hosts the text view never reads the status.
+@MainActor struct DocsSubtitleView: View {
+ let model: DocsModel
+ let team: String?
+ @Environment(\.locale) private var locale
+ /// The 1 s debounce for row 9, set only from the `.task` below.
+ @State private var savingShown = false
+ @State private var announced: DocsSubtitleRow?
+
+ var body: some View {
+ let status = model.syncStatus
+ let row = DocsSubtitleRow(access: model.access, status: status, savingShown: savingShown, loading: model.projection == nil)
+ DocsSubtitleLine(row: row, team: team, strings: DocsStrings(locale: locale))
+ // Not `.saved` continuously for a second shows "Saving…"; every
+ // return to `.saved` restarts the clock (spec §6, row 9).
+ .task(id: Self.unsettled(status, draft: model.isDraft)) {
+ guard Self.unsettled(status, draft: model.isDraft) else { savingShown = false; return }
+ try? await Task.sleep(for: .seconds(1))
+ if !Task.isCancelled { savingShown = true }
+ }
+ .onChange(of: row, initial: true) { old, new in
+ defer { announced = new }
+ guard let previous = announced, previous != new, DocsSubtitleRow.announces(from: old, to: new) else { return }
+ let strings = DocsStrings(locale: locale)
+ AccessibilityNotification.Announcement(strings.state(new) ?? "").post()
+ }
+ }
+ static func unsettled(_ status: SyncStatus, draft: Bool) -> Bool { draft || status != .saved }
+}
+
+/// The subtitle's drawing, given its row: muted, or negative (semibold for
+/// row 2), with an eye for View only. One accessibility element, present
+/// even when quiet, that updates frequently.
+struct DocsSubtitleLine: View {
+ let row: DocsSubtitleRow
+ let team: String?
+ let strings: DocsStrings
+ var body: some View {
+ let text = strings.subtitle(team: team, row: row)
+ HStack(spacing: 4) {
+ if row == .viewOnly { Image(systemName: "eye").font(.system(size: 9, weight: .semibold)) }
+ Text(verbatim: text.isEmpty ? " " : text)
+ .lineLimit(1)
+ .truncationMode(.tail)
+ }
+ .font(.system(size: 11, weight: row.isEmphasised ? .semibold : .regular))
+ .foregroundStyle(row.isNegative ? OficinaPalette.negative : OficinaPalette.textMuted)
+ .accessibilityElement(children: .ignore)
+ .accessibilityLabel(Text(verbatim: text))
+ .accessibilityAddTraits(.updatesFrequently)
+ .accessibilityIdentifier("docs.document.subtitle")
+ }
+}
diff --git a/native/apple/Sources/DocsKit/DocsToolsControls.swift b/native/apple/Sources/DocsKit/DocsToolsControls.swift
index a8858e7..8c364ef 100644
--- a/native/apple/Sources/DocsKit/DocsToolsControls.swift
+++ b/native/apple/Sources/DocsKit/DocsToolsControls.swift
@@ -19,53 +19,69 @@ struct DocsToolsControls: View {
} label: {
Label { Text("docs.editor.menu.tools", bundle: DocsResources.bundle) } icon: { Image(systemName: "wrench.and.screwdriver") }
}
- .sheet(isPresented: $showingShortcuts) {
- NavigationStack {
- Form {
- ForEach(DocumentKeyboardBindings.all) { binding in
- LabeledContent {
- Text(binding.display).monospaced()
- } label: {
- Text(LocalizedStringKey(binding.titleKey), bundle: DocsResources.bundle)
- }
+ .sheet(isPresented: $showingShortcuts) { DocsShortcutsSheet { showingShortcuts = false } }
+ .sheet(isPresented: $showingCount) { DocsWordCountSheet(projection: projection, content: content, selection: selection) { showingCount = false } }
+ }
+
+}
+
+/// Keyboard shortcuts, as a sheet: Tools on the iPhone, Help ▸ Keyboard
+/// shortcuts… on the Mac.
+@MainActor struct DocsShortcutsSheet: View {
+ let close: () -> Void
+ var body: some View {
+ NavigationStack {
+ Form {
+ ForEach(DocumentKeyboardBindings.all) { binding in
+ LabeledContent {
+ Text(binding.display).monospaced()
+ } label: {
+ Text(LocalizedStringKey(binding.titleKey), bundle: DocsResources.bundle)
}
}
- .navigationTitle(Text("docs.editor.shortcuts.title", bundle: DocsResources.bundle))
- .toolbar {
- ToolbarItem(placement: .confirmationAction) {
- Button { showingShortcuts = false } label: { Text("docs.editor.shortcuts.close", bundle: DocsResources.bundle) }
- }
+ }
+ .navigationTitle(Text("docs.editor.shortcuts.title", bundle: DocsResources.bundle))
+ .toolbar {
+ ToolbarItem(placement: .confirmationAction) {
+ Button { close() } label: { Text("docs.editor.shortcuts.close", bundle: DocsResources.bundle) }
}
}
- #if os(macOS)
- .frame(minWidth: 420, minHeight: 420)
- #endif
}
- .sheet(isPresented: $showingCount) {
- let count = DocumentWordCounts(projection: projection, content: content, selection: selection)
- NavigationStack {
- Form {
- row("docs.editor.wordcount.words", count.words)
- row("docs.editor.wordcount.characters", count.characters)
- row("docs.editor.wordcount.charactersnospaces", count.charactersNoSpaces)
- row("docs.editor.wordcount.paragraphs", count.paragraphs)
- if let selected = count.selectedWords { row("docs.editor.wordcount.selection", selected) }
- }
- .navigationTitle(Text("docs.editor.wordcount.title", bundle: DocsResources.bundle))
- .toolbar {
- ToolbarItem(placement: .confirmationAction) {
- Button { showingCount = false } label: { Text("docs.editor.wordcount.close", bundle: DocsResources.bundle) }
- }
+ #if os(macOS)
+ .frame(minWidth: 420, minHeight: 420)
+ #endif
+ }
+}
+
+/// Word count, as a sheet: Tools on the iPhone, Tools ▸ Word count… on the Mac.
+@MainActor struct DocsWordCountSheet: View {
+ let projection: CRDTProjection
+ let content: NSAttributedString
+ let selection: NSRange
+ let close: () -> Void
+ var body: some View {
+ let count = DocumentWordCounts(projection: projection, content: content, selection: selection)
+ NavigationStack {
+ Form {
+ row("docs.editor.wordcount.words", count.words)
+ row("docs.editor.wordcount.characters", count.characters)
+ row("docs.editor.wordcount.charactersnospaces", count.charactersNoSpaces)
+ row("docs.editor.wordcount.paragraphs", count.paragraphs)
+ if let selected = count.selectedWords { row("docs.editor.wordcount.selection", selected) }
+ }
+ .navigationTitle(Text("docs.editor.wordcount.title", bundle: DocsResources.bundle))
+ .toolbar {
+ ToolbarItem(placement: .confirmationAction) {
+ Button { close() } label: { Text("docs.editor.wordcount.close", bundle: DocsResources.bundle) }
}
}
- #if os(macOS)
- .frame(minWidth: 360, minHeight: 290)
- #else
- .presentationDetents([.medium])
- #endif
}
+ #if os(macOS)
+ .frame(minWidth: 360, minHeight: 290)
+ #else
+ .presentationDetents([.medium])
+ #endif
}
-
private func row(_ key: LocalizedStringKey, _ value: Int) -> some View {
LabeledContent { Text(value, format: .number).monospacedDigit() } label: { Text(key, bundle: DocsResources.bundle) }
}
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift
index 918d3f4..3b5a3cd 100644
--- a/native/apple/Sources/DocsKit/DocsWorkspace.swift
+++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift
@@ -14,6 +14,8 @@ import SwiftUI
@Environment(\.openWindow) private var openWindow
@Environment(\.scenePhase) private var scenePhase
@State private var jumping = false
+ @State private var countingWords = false
+ @State private var showingShortcuts = false
@State private var showingColophon = false
@State private var discarding = false
@State private var images = DocsImageStore()
@@ -33,7 +35,15 @@ import SwiftUI
private let documentID: String?
private let openDocument: ((String, String) -> Void)?
@State private var zoom = 1.0
- @State private var inspecting = false
+ #if os(macOS)
+ /// The floating Format inspector, one state for the whole app (spec D1).
+ @AppStorage(DocsInspectorState.key) private var inspectorOpen = DocsInspectorState.defaultOpen
+ @Environment(\.layoutDirection) private var layoutDirection
+ @Environment(\.dismiss) private var dismissWindow
+ #endif
+ /// The subtitle's team (spec D7): the account's team, or the server
+ /// account's name. nil says the state alone.
+ private let team: String?
private let signOut: () -> Void
private let accounts: (() -> Void)?
private let client: NativeHTTP
@@ -43,7 +53,8 @@ import SwiftUI
@State private var signOutRefusal: DocsLeaveBlock?
/// `transport` supplies the account's current session to the model on every
/// request; without one the model keeps `client` for its whole lifetime.
- public init(client: NativeHTTP, accountID: String? = nil, transport: (@MainActor () -> NativeTransport?)? = nil, accounts: (() -> Void)? = nil, signOut: @escaping () -> Void, documentID: String? = nil, newDocument: Bool = false, createDocument: (() -> Void)? = nil, documentChanged: ((String, String) -> Void)? = nil, canSignOut: Bool = true, createRequested: Binding<Bool> = .constant(false), accountsRequested: Binding<Bool> = .constant(false), signOutRequested: Binding<Bool> = .constant(false), accountsLabel: String? = nil, signOutLabel: String? = nil, useAnother: (() -> Void)? = nil, openDocument: ((String, String) -> Void)? = nil, updateRecents: (([(String, String)]) -> Void)? = nil) {
+ public init(client: NativeHTTP, accountID: String? = nil, transport: (@MainActor () -> NativeTransport?)? = nil, accounts: (() -> Void)? = nil, signOut: @escaping () -> Void, documentID: String? = nil, newDocument: Bool = false, createDocument: (() -> Void)? = nil, documentChanged: ((String, String) -> Void)? = nil, canSignOut: Bool = true, createRequested: Binding<Bool> = .constant(false), accountsRequested: Binding<Bool> = .constant(false), signOutRequested: Binding<Bool> = .constant(false), accountsLabel: String? = nil, signOutLabel: String? = nil, useAnother: (() -> Void)? = nil, openDocument: ((String, String) -> Void)? = nil, updateRecents: (([(String, String)]) -> Void)? = nil, team: String? = nil) {
+ self.team = team
self._signOutRequested = signOutRequested; self.accountsLabel = accountsLabel; self.signOutLabel = signOutLabel; self.useAnother = useAnother
self.updateRecents = updateRecents; self.canSignOut = canSignOut; self._createRequested = createRequested; self._accountsRequested = accountsRequested; self.documentID = documentID; self.openDocument = openDocument
self.newDocument = newDocument; self.createDocument = createDocument; self.documentChanged = documentChanged
@@ -137,7 +148,7 @@ import SwiftUI
.onChange(of: [model.detail?.sqid, model.detail?.title]) {
if !model.isDraft, let detail = model.detail { documentChanged?(detail.sqid, detail.title) }
}
- .sheet(isPresented: $jumping) { DocsJumpSheet(model: model, client: liveClient) }
+ .sheet(isPresented: $jumping) { DocsJumpSheet(model: model, client: liveClient, openElsewhere: jumpOpensWindows ? openDocument : nil) }
.onDisappear { Task { await model.stop() } }
.onChange(of: scenePhase) { _, phase in
#if os(iOS)
@@ -196,6 +207,7 @@ import SwiftUI
guard renaming else { return }
if model.commitRename() { renaming = false }
}
+ #if os(iOS)
private var documentTitle: some View {
Group {
if renaming {
@@ -220,9 +232,31 @@ import SwiftUI
}
}
}
+ #endif
+ /// On the Mac, a jump from a document or the home window opens or
+ /// focuses the result's own window instead of replacing this one.
+ private var jumpOpensWindows: Bool {
+ #if os(macOS)
+ true
+ #else
+ false
+ #endif
+ }
+ #if os(macOS)
+ /// Share… flushes first, as today; S2b replaces the sheet with a popover.
+ private func share() {
+ Task { await model.flush(); if !model.hasUnsavedChanges { sharing = true } }
+ }
+ /// A writer's window shows the inspector when the app-wide state says
+ /// open; a reader's never does, and never writes the state (spec §1).
+ private var showsInspector: Bool { inspectorOpen && model.access == .writable }
+ #endif
private var editor: some View {
VStack(spacing: 0) {
+ #if os(iOS)
NativeSyncStatusView(status: model.syncStatus)
+ #endif
+ #if os(iOS)
if let key = model.errorKey {
HStack {
Text(LocalizedStringKey(key), bundle: DocsResources.bundle)
@@ -232,31 +266,65 @@ import SwiftUI
}
}.padding().accessibilityElement(children: .contain)
}
+ #endif
if model.loading { ProgressView() }
if let projection = model.projection {
let documentPath = "/d/" + (model.detail?.sqid ?? "")
let text = NativeTextProjection.render(projection, images: images.images(forDocumentPath: documentPath, client: liveClient))
+ #if os(iOS)
EditorToolbar(model: model, content: text)
Divider()
+ #endif
NativeDocumentTextView(content: text, generation: model.projectionGeneration, didRender: model.didRender, compositionChanged: model.compositionChanged, isEditable: model.detail?.can_write == true && !model.inputPaused, paged: paged, pendingInput: model.hasPendingInput, canRender: model.canRender, currentSelection: model.currentSelection, selection: $model.selection, edit: model.enqueue, action: { action in
if action == "jump" {
- #if os(macOS)
- openWindow(id: "home")
- #else
+ // Open a document… (⌘K): the jump palette as a sheet
+ // over this window, on the Mac too (spec §1, menus).
jumping = true
- #endif
return true
}
return DocumentCommands(model: model, content: text).perform(action)
}, selectionMoved: model.selectionMovedExplicitly, canAction: { action in model.detail?.can_write == true && !model.hasPendingInput && !model.composing && !model.inputPaused && (action == "undo" ? projection.canUndo : projection.canRedo) }, explicitCommandRevision: model.explicitCommandRevision, zoom: zoom, typingMarks: model.typingMarks)
+ #if os(macOS)
+ .inspectorSide(showsInspector ? (layoutDirection == .rightToLeft ? .left : .right) : nil)
+ #endif
.id(model.editorIdentity)
+ #if os(macOS)
+ .overlay(alignment: .topTrailing) {
+ if showsInspector {
+ DocsFormatInspector(model: model, content: text)
+ .padding(.top, DocsDeskLayout.inspectorInset)
+ .padding(.trailing, DocsDeskLayout.inspectorInset)
+ }
+ }
+ #endif
.task(id: [documentPath] + DocsImageStore.sources(in: projection)) { await images.load(sources: DocsImageStore.sources(in: projection), client: liveClient, documentPath: documentPath) }
} else {
ContentUnavailableView { Label { Text("native.open", bundle: DocsResources.bundle) } icon: { Image(systemName: "doc.text") } }
}
}.navigationTitle(model.detail?.title ?? "")
+ #if os(macOS)
+ // One title (spec §1): the window's title stays the document's,
+ // for the Window menu, tabs and VoiceOver, but the system does
+ // not draw it; Docs' title area does, with the subtitle.
+ .overlay(alignment: .top) { DocsDocumentCallouts(model: model, discard: { discarding = true }, close: { dismissWindow() }) }
+ .toolbar(removing: .title)
+ .toolbar {
+ ToolbarItem(placement: .navigation) {
+ DocsTitleArea(model: model, team: team, renaming: $renaming, beginRename: beginRename, finishRename: finishRename)
+ }
+ .sharedBackgroundVisibility(.hidden)
+ ToolbarSpacer(.flexible)
+ // Three items, so a narrow window moves them into the » menu
+ // one at a time: Share… first, then Format, then undo/redo.
+ ToolbarItem(placement: .primaryAction) { DocsHeaderControls(model: model, inspectorOpen: $inspectorOpen, part: .history, share: share) }
+ .sharedBackgroundVisibility(.hidden)
+ ToolbarItem(placement: .primaryAction) { DocsHeaderControls(model: model, inspectorOpen: $inspectorOpen, part: .format, share: share) }
+ .sharedBackgroundVisibility(.hidden)
+ ToolbarItem(placement: .primaryAction) { DocsHeaderControls(model: model, inspectorOpen: $inspectorOpen, part: .share, share: share) }
+ .sharedBackgroundVisibility(.hidden)
+ }
+ #else
.toolbar { ToolbarItem(placement: .principal) { documentTitle } }
- #if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
#if os(iOS)
@@ -282,30 +350,14 @@ import SwiftUI
.frame(width: 0, height: 0).hidden().accessibilityHidden(true)
}
}
- .toolbar { Button(docsMacString("Inspector"), systemImage: "sidebar.right") { inspecting.toggle() } }
- // A closed SwiftUI inspector can repeatedly invalidate hosting-view
- // constraints on macOS 27 while the editor loads. Keep this panel in
- // the ordinary view layout so opening a document has stable sizing.
- .safeAreaInset(edge: .trailing, spacing: 0) {
- if inspecting {
- Form {
- LabeledContent(docsMacString("Document"), value: model.detail?.title ?? "")
- Picker(docsMacString("Zoom"), selection: $zoom) {
- ForEach([0.5, 0.75, 1.0, 1.25, 1.5, 2.0], id: \.self) { value in
- Text(value, format: .percent).tag(value)
- }
- }
- Toggle(docsMacString("Pages"), isOn: $paged)
- if let projection = model.projection {
- DocsToolsControls(projection: projection, content: NativeTextProjection.render(projection), selection: model.selection)
- }
- }.formStyle(.grouped).frame(width: 280)
- .frame(maxHeight: .infinity)
- .background(.background)
- .overlay(alignment: .leading) { Divider() }
+ .focusedSceneValue(\.docsJump, $jumping)
+ .focusedSceneValue(\.docsEditor, DocsEditorContext(model: model, rename: beginRename, client: liveClient, zoom: $zoom, paged: $paged, sharing: $sharing, exportRequest: $exportRequest, jumping: $jumping, wordCount: $countingWords, shortcuts: $showingShortcuts))
+ .sheet(isPresented: $countingWords) {
+ if let projection = model.projection {
+ DocsWordCountSheet(projection: projection, content: NativeTextProjection.render(projection), selection: model.selection) { countingWords = false }
}
}
- .focusedSceneValue(\.docsEditor, DocsEditorContext(model: model, rename: beginRename, client: liveClient, zoom: $zoom, paged: $paged, inspecting: $inspecting, sharing: $sharing, exportRequest: $exportRequest))
+ .sheet(isPresented: $showingShortcuts) { DocsShortcutsSheet { showingShortcuts = false } }
#endif
}
@@ -345,6 +397,7 @@ import SwiftUI
.navigationTitle(docsMacString("Home"))
.searchable(text: $query, prompt: Text("docs.list.search.label", bundle: DocsResources.bundle))
.onSubmit(of: .search) { Task { await model.load(query: query) } }
+ .focusedSceneValue(\.docsJump, $jumping)
.focusedSceneValue(\.docsAccountActions, DocsAccountActions(accounts: accounts, signOut: signOut, canManage: !model.creatingDocument, canSignOut: canSignOut && !model.creatingDocument,
useAnother: useAnother, accountsLabel: accountsLabel, signOutLabel: signOutLabel))
.toolbar {
diff --git a/native/apple/Sources/DocsKit/NativeDocumentTextView.swift b/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
index ed82c36..0c57811 100644
--- a/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
+++ b/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
@@ -21,6 +21,9 @@ struct NativeDocumentTextView: NSViewRepresentable {
/// Marks chosen at a collapsed caret (DocsModel.typingMarks), so marked
/// text is drawn in the face it will commit in.
var typingMarks: [String: JSONValue]? = nil
+ /// The side the floating inspector covers, nil while it is hidden: the
+ /// desk centres the page clear of it (spec §1, page centring).
+ var inspector: DocsDeskLayout.Side? = nil
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeNSView(context: Context) -> NSScrollView {
let scroll = NSScrollView()
@@ -32,8 +35,8 @@ struct NativeDocumentTextView: NSViewRepresentable {
scroll.magnification = 4.0 / 3.0
let text = DocsTextView(frame: .zero)
text.isVerticallyResizable = false
- text.autoresizingMask = [.width]
- scroll.documentView = text
+ // The page is a fixed paper band on the desk, which centres it (S2a).
+ scroll.documentView = DocsDeskView(page: text)
text.delegate = context.coordinator
let coordinator = context.coordinator
text.action = { [weak text] action in
@@ -58,7 +61,8 @@ struct NativeDocumentTextView: NSViewRepresentable {
return scroll
}
func updateNSView(_ scroll: NSScrollView, context: Context) {
- guard let text = scroll.documentView as? NSTextView else { return }
+ guard let desk = scroll.documentView as? DocsDeskView, let text = desk.page as? NSTextView else { return }
+ desk.inspector = inspector
let magnification = zoom * 4.0 / 3.0
if abs(scroll.magnification - magnification) > 0.001 {
scroll.setMagnification(magnification, centeredAt: scroll.contentView.bounds.origin)
diff --git a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
index a2c0b6a..56dde3f 100644
--- a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "تسجيل الدخول…";
"native.leave.sending" = "لا يزال Docs يرسل التغييرات. حاول مرة أخرى بعد حفظها.";
"native.leave.openDocuments" = "أغلق المستندات المفتوحة لهذا الحساب أولًا.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "السجل";
+"docs.editor.toolbar.group.style" = "النمط";
+"docs.editor.toolbar.group.text" = "النص";
+"docs.editor.toolbar.group.align" = "المحاذاة";
+"docs.editor.toolbar.group.lists" = "القوائم";
+"docs.editor.inspector.label" = "تنسيق";
+"docs.editor.inspector.toggle" = "تنسيق";
+"docs.share.action" = "مشاركة…";
+"native.subtitle.saved" = "تم الحفظ";
+"native.subtitle.viewOnly" = "للعرض فقط";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "لم يعد متاحًا";
+"native.unavailable.body" = "حُذف هذا المستند أو لم يعد مشتركًا معك.";
+"native.subtitle.signedOut" = "تم تسجيل الخروج";
+"native.format.show" = "إظهار التنسيق";
+"native.format.hide" = "إخفاء التنسيق";
diff --git a/native/apple/Sources/DocsKit/Resources/ar.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/ar.lproj/Mac.strings
index 0f71091..aa6fa41 100644
--- a/native/apple/Sources/DocsKit/Resources/ar.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/ar.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "الحسابات";
"Actual size" = "الحجم الفعلي";
-"Alignment" = "المحاذاة";
-"Block quote" = "كتلة اقتباس";
-"Bold" = "عريض";
-"Bullet list" = "قائمة نقطية";
"Cell contents" = "محتوى الخلية";
-"Clear formatting" = "مسح التنسيق";
"Close this account’s document windows before signing out." = "أغلق نوافذ مستندات هذا الحساب قبل تسجيل الخروج.";
"Create a document to get started." = "ستظهر المستندات التي تنشئها هنا، بدءًا بالأحدث.";
"Docs" = "Docs";
-"Document" = "المستند";
-"Document inspector" = "خصائص المستند";
"Double-click to fit column to contents" = "انقر مرتين لملاءمة العمود للمحتوى";
"Edit %@" = "تحرير %@";
"Export" = "تصدير";
"Fit column to contents" = "ملاءمة العمود للمحتوى";
-"Font" = "الخط";
-"Format" = "تنسيق";
"Heading %d" = "العنوان %d";
"Home" = "الرئيسية";
-"Indent" = "زيادة المسافة البادئة";
-"Inline code" = "شيفرة";
-"Inspector" = "خصائص المستند";
-"Italic" = "مائل";
"Markdown…" = "Markdown";
"New document" = "مستند جديد";
"No documents" = "لا توجد مستندات بعد";
"No recent documents" = "لا توجد مستندات بعد";
-"Normal" = "نص أساسي";
-"Numbered list" = "قائمة مرقّمة";
"Open a document from Home" = "افتح مستندًا من الرئيسية";
-"Outdent" = "تقليل المسافة البادئة";
"PDF…" = "PDF";
-"Pages" = "صفحات";
-"Paragraph style" = "نمط الفقرة";
"Print…" = "طباعة";
"Recent" = "الأخيرة";
"Recent documents" = "المستندات الأخيرة";
@@ -43,9 +25,7 @@
"Select column %@" = "تحديد العمود %@";
"Select row %d" = "تحديد الصف %d";
"Shared" = "تمت مشاركتها معك";
-"Share…" = "مشاركة";
"Sign out" = "تسجيل الخروج";
-"Size" = "الحجم";
"Zoom" = "التكبير";
"Untitled document" = "مستند بلا عنوان";
diff --git a/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
index 14855a7..cb452a4 100644
--- a/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "সাইন ইন করুন…";
"native.leave.sending" = "Docs এখনও পরিবর্তন পাঠাচ্ছে। সেগুলি সংরক্ষিত হলে আবার চেষ্টা করুন।";
"native.leave.openDocuments" = "প্রথমে এই অ্যাকাউন্টের খোলা ডকুমেন্টগুলি বন্ধ করুন।";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "ইতিহাস";
+"docs.editor.toolbar.group.style" = "শৈলী";
+"docs.editor.toolbar.group.text" = "টেক্সট";
+"docs.editor.toolbar.group.align" = "সারিবদ্ধতা";
+"docs.editor.toolbar.group.lists" = "তালিকা";
+"docs.editor.inspector.label" = "বিন্যাস";
+"docs.editor.inspector.toggle" = "বিন্যাস";
+"docs.share.action" = "শেয়ার করুন…";
+"native.subtitle.saved" = "সংরক্ষিত";
+"native.subtitle.viewOnly" = "শুধু দেখার জন্য";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "আর উপলভ্য নেই";
+"native.unavailable.body" = "এই নথিটি মুছে ফেলা হয়েছে বা আর আপনার সঙ্গে শেয়ার করা নেই।";
+"native.subtitle.signedOut" = "সাইন আউট করা হয়েছে";
+"native.format.show" = "বিন্যাস দেখান";
+"native.format.hide" = "বিন্যাস লুকান";
diff --git a/native/apple/Sources/DocsKit/Resources/bn.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/bn.lproj/Mac.strings
index e5ef63c..a71a8b2 100644
--- a/native/apple/Sources/DocsKit/Resources/bn.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/bn.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "অ্যাকাউন্ট";
"Actual size" = "প্রকৃত আকার";
-"Alignment" = "প্রান্তিককরণ";
-"Block quote" = "উদ্ধৃতির ব্লক";
-"Bold" = "গাঢ়";
-"Bullet list" = "বুলেটযুক্ত তালিকা";
"Cell contents" = "ঘরের বিষয়বস্তু";
-"Clear formatting" = "বিন্যাস মুছুন";
"Close this account’s document windows before signing out." = "সাইন আউট করার আগে এই অ্যাকাউন্টের নথির উইন্ডোগুলি বন্ধ করুন।";
"Create a document to get started." = "আপনার তৈরি নথি এখানে দেখা যাবে, নতুনগুলো আগে।";
"Docs" = "Docs";
-"Document" = "নথি";
-"Document inspector" = "নথি পরিদর্শক";
"Double-click to fit column to contents" = "বিষয়বস্তু অনুযায়ী কলাম মাপতে দুবার ক্লিক করুন";
"Edit %@" = "%@ সম্পাদনা করুন";
"Export" = "রপ্তানি";
"Fit column to contents" = "বিষয়বস্তু অনুযায়ী কলাম মাপুন";
-"Font" = "ফন্ট";
-"Format" = "বিন্যাস";
"Heading %d" = "শিরোনাম %d";
"Home" = "হোম";
-"Indent" = "ইন্ডেন্ট বাড়ান";
-"Inline code" = "কোড";
-"Inspector" = "নথি পরিদর্শক";
-"Italic" = "তির্যক";
"Markdown…" = "Markdown";
"New document" = "নতুন নথি";
"No documents" = "এখনও কোনো নথি নেই";
"No recent documents" = "এখনও কোনো নথি নেই";
-"Normal" = "মূল পাঠ্য";
-"Numbered list" = "সংখ্যাযুক্ত তালিকা";
"Open a document from Home" = "হোম থেকে একটি নথি খুলুন";
-"Outdent" = "ইন্ডেন্ট কমান";
"PDF…" = "PDF";
-"Pages" = "পৃষ্ঠাভিত্তিক";
-"Paragraph style" = "অনুচ্ছেদের শৈলী";
"Print…" = "প্রিন্ট করুন";
"Recent" = "সাম্প্রতিক";
"Recent documents" = "সাম্প্রতিক নথি";
@@ -43,9 +25,7 @@
"Select column %@" = "কলাম %@ নির্বাচন করুন";
"Select row %d" = "সারি %d নির্বাচন করুন";
"Shared" = "আপনার সঙ্গে শেয়ার করা";
-"Share…" = "শেয়ার করুন";
"Sign out" = "সাইন আউট করুন";
-"Size" = "আকার";
"Zoom" = "জুম";
"Untitled document" = "শিরোনামহীন নথি";
diff --git a/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
index 5a3688f..4e3eb18 100644
--- a/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
@@ -210,3 +210,21 @@
"native.settings.signIn" = "Sign in…";
"native.leave.sending" = "Docs is still sending changes. Try again once they’re saved.";
"native.leave.openDocuments" = "Close this account’s open documents first.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "History";
+"docs.editor.toolbar.group.style" = "Style";
+"docs.editor.toolbar.group.text" = "Text";
+"docs.editor.toolbar.group.align" = "Alignment";
+"docs.editor.toolbar.group.lists" = "Lists";
+"docs.editor.inspector.label" = "Format";
+"docs.editor.inspector.toggle" = "Format";
+"docs.share.action" = "Share…";
+"native.subtitle.saved" = "Saved";
+"native.subtitle.viewOnly" = "View only";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "No longer available";
+"native.unavailable.body" = "This document was deleted or is no longer shared with you.";
+"native.subtitle.signedOut" = "Signed out";
+"native.format.show" = "Show Format";
+"native.format.hide" = "Hide Format";
diff --git a/native/apple/Sources/DocsKit/Resources/en.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/en.lproj/Mac.strings
index 257c19e..64ea587 100644
--- a/native/apple/Sources/DocsKit/Resources/en.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/en.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Accounts";
"Actual size" = "Actual size";
-"Alignment" = "Alignment";
-"Block quote" = "Block quote";
-"Bold" = "Bold";
-"Bullet list" = "Bulleted list";
"Cell contents" = "Cell contents";
-"Clear formatting" = "Clear formatting";
"Close this account’s document windows before signing out." = "Close this account’s document windows before signing out.";
"Create a document to get started." = "Documents you create will show up here, newest first.";
"Docs" = "Docs";
-"Document" = "Document";
-"Document inspector" = "Document inspector";
"Double-click to fit column to contents" = "Double-click to fit column to contents";
"Edit %@" = "Edit %@";
"Export" = "Export";
"Fit column to contents" = "Fit column to contents";
-"Font" = "Font";
-"Format" = "Format";
"Heading %d" = "Heading %d";
"Home" = "Home";
-"Indent" = "Increase indent";
-"Inline code" = "Code";
-"Inspector" = "Document inspector";
-"Italic" = "Italic";
"Markdown…" = "Markdown";
"New document" = "New document";
"No documents" = "No documents yet";
"No recent documents" = "No documents yet";
-"Normal" = "Body text";
-"Numbered list" = "Numbered list";
"Open a document from Home" = "Open a document from Home";
-"Outdent" = "Decrease indent";
"PDF…" = "PDF";
-"Pages" = "Paged";
-"Paragraph style" = "Paragraph style";
"Print…" = "Print";
"Recent" = "Recent";
"Recent documents" = "Recent documents";
@@ -43,9 +25,7 @@
"Select column %@" = "Select column %@";
"Select row %d" = "Select row %d";
"Shared" = "Shared with you";
-"Share…" = "Share";
"Sign out" = "Sign out";
-"Size" = "Size";
"Zoom" = "Zoom";
"Untitled document" = "Untitled document";
diff --git a/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
index b068458..d28d117 100644
--- a/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "Iniciar sesión…";
"native.leave.sending" = "Docs todavía está enviando cambios. Inténtalo de nuevo cuando se hayan guardado.";
"native.leave.openDocuments" = "Cierra primero los documentos abiertos de esta cuenta.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "Historial";
+"docs.editor.toolbar.group.style" = "Estilo";
+"docs.editor.toolbar.group.text" = "Texto";
+"docs.editor.toolbar.group.align" = "Alineación";
+"docs.editor.toolbar.group.lists" = "Listas";
+"docs.editor.inspector.label" = "Formato";
+"docs.editor.inspector.toggle" = "Formato";
+"docs.share.action" = "Compartir…";
+"native.subtitle.saved" = "Guardado";
+"native.subtitle.viewOnly" = "Solo lectura";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "Ya no está disponible";
+"native.unavailable.body" = "Este documento se eliminó o ya no se comparte contigo.";
+"native.subtitle.signedOut" = "Sesión cerrada";
+"native.format.show" = "Mostrar Formato";
+"native.format.hide" = "Ocultar Formato";
diff --git a/native/apple/Sources/DocsKit/Resources/es.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/es.lproj/Mac.strings
index 3568620..57ff6ba 100644
--- a/native/apple/Sources/DocsKit/Resources/es.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/es.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Cuentas";
"Actual size" = "Tamaño real";
-"Alignment" = "Alineación";
-"Block quote" = "Cita en bloque";
-"Bold" = "Negrita";
-"Bullet list" = "Lista con viñetas";
"Cell contents" = "Contenido de la celda";
-"Clear formatting" = "Borrar formato";
"Close this account’s document windows before signing out." = "Cierra las ventanas de documentos de esta cuenta antes de cerrar sesión.";
"Create a document to get started." = "Los documentos que crees aparecerán aquí, empezando por los más recientes.";
"Docs" = "Docs";
-"Document" = "Documento";
-"Document inspector" = "Inspector del documento";
"Double-click to fit column to contents" = "Haz doble clic para ajustar la columna al contenido";
"Edit %@" = "Editar %@";
"Export" = "Exportar";
"Fit column to contents" = "Ajustar columna al contenido";
-"Font" = "Fuente";
-"Format" = "Formato";
"Heading %d" = "Título %d";
"Home" = "Inicio";
-"Indent" = "Aumentar sangría";
-"Inline code" = "Código";
-"Inspector" = "Inspector del documento";
-"Italic" = "Cursiva";
"Markdown…" = "Markdown";
"New document" = "Nuevo documento";
"No documents" = "Aún no hay documentos";
"No recent documents" = "Aún no hay documentos";
-"Normal" = "Texto del cuerpo";
-"Numbered list" = "Lista numerada";
"Open a document from Home" = "Abre un documento desde Inicio";
-"Outdent" = "Reducir sangría";
"PDF…" = "PDF";
-"Pages" = "Por páginas";
-"Paragraph style" = "Estilo de párrafo";
"Print…" = "Imprimir";
"Recent" = "Recientes";
"Recent documents" = "Documentos recientes";
@@ -43,9 +25,7 @@
"Select column %@" = "Seleccionar columna %@";
"Select row %d" = "Seleccionar fila %d";
"Shared" = "Compartidos contigo";
-"Share…" = "Compartir";
"Sign out" = "Cerrar sesión";
-"Size" = "Tamaño";
"Zoom" = "Zoom";
"Untitled document" = "Documento sin título";
diff --git a/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
index 145a95a..e126b9c 100644
--- a/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "Sínigh isteach…";
"native.leave.sending" = "Tá Docs fós ag seoladh athruithe. Bain triail eile as nuair a bheidh siad sábháilte.";
"native.leave.openDocuments" = "Dún doiciméid oscailte an chuntais seo ar dtús.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "Stair";
+"docs.editor.toolbar.group.style" = "Stíl";
+"docs.editor.toolbar.group.text" = "Téacs";
+"docs.editor.toolbar.group.align" = "Ailíniú";
+"docs.editor.toolbar.group.lists" = "Liostaí";
+"docs.editor.inspector.label" = "Formáid";
+"docs.editor.inspector.toggle" = "Formáid";
+"docs.share.action" = "Comhroinn…";
+"native.subtitle.saved" = "Sábháilte";
+"native.subtitle.viewOnly" = "Léamh amháin";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "Níl sé ar fáil a thuilleadh";
+"native.unavailable.body" = "Scriosadh an doiciméad seo nó níl sé comhroinnte leat a thuilleadh.";
+"native.subtitle.signedOut" = "Sínithe amach";
+"native.format.show" = "Taispeáin Formáid";
+"native.format.hide" = "Folaigh Formáid";
diff --git a/native/apple/Sources/DocsKit/Resources/ga.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/ga.lproj/Mac.strings
index 4be5249..049b4ba 100644
--- a/native/apple/Sources/DocsKit/Resources/ga.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/ga.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Cuntais";
"Actual size" = "Fíormhéid";
-"Alignment" = "Ailíniú";
-"Block quote" = "Athfhriotal i mbloc";
-"Bold" = "Trom";
-"Bullet list" = "Liosta le hurchair";
"Cell contents" = "Ábhar na cille";
-"Clear formatting" = "Glan an fhormáidiú";
"Close this account’s document windows before signing out." = "Dún fuinneoga cáipéisí an chuntais seo sula síníonn tú amach.";
"Create a document to get started." = "Beidh na doiciméid a chruthaíonn tú anseo, na cinn is nua ar dtús.";
"Docs" = "Docs";
-"Document" = "Cáipéis";
-"Document inspector" = "Cigire cáipéise";
"Double-click to fit column to contents" = "Déchliceáil chun an colún a oiriúnú don ábhar";
"Edit %@" = "Cuir %@ in eagar";
"Export" = "Easpórtáil";
"Fit column to contents" = "Oiriúnaigh an colún don ábhar";
-"Font" = "Cló";
-"Format" = "Formáid";
"Heading %d" = "Ceannteideal %d";
"Home" = "Baile";
-"Indent" = "Méadaigh an eangú";
-"Inline code" = "Cód";
-"Inspector" = "Cigire cáipéise";
-"Italic" = "Iodálach";
"Markdown…" = "Markdown";
"New document" = "Doiciméad nua";
"No documents" = "Níl aon doiciméid ann fós";
"No recent documents" = "Níl aon doiciméid ann fós";
-"Normal" = "Téacs coirp";
-"Numbered list" = "Liosta uimhrithe";
"Open a document from Home" = "Oscail cáipéis ón mBaile";
-"Outdent" = "Laghdaigh an eangú";
"PDF…" = "PDF";
-"Pages" = "Leathanaigh";
-"Paragraph style" = "Stíl ailt";
"Print…" = "Priontáil";
"Recent" = "Le déanaí";
"Recent documents" = "Cáipéisí le déanaí";
@@ -43,9 +25,7 @@
"Select column %@" = "Roghnaigh colún %@";
"Select row %d" = "Roghnaigh ró %d";
"Shared" = "Comhroinnte leat";
-"Share…" = "Comhroinn";
"Sign out" = "Sínigh amach";
-"Size" = "Méid";
"Zoom" = "Súmáil";
"Untitled document" = "Doiciméad gan teideal";
diff --git a/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
index 2f8bcc7..7db50e3 100644
--- a/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "साइन इन करें…";
"native.leave.sending" = "Docs अभी भी बदलाव भेज रहा है। उनके सहेजे जाने के बाद फिर से कोशिश करें।";
"native.leave.openDocuments" = "पहले इस खाते के खुले दस्तावेज़ बंद करें।";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "इतिहास";
+"docs.editor.toolbar.group.style" = "शैली";
+"docs.editor.toolbar.group.text" = "टेक्स्ट";
+"docs.editor.toolbar.group.align" = "संरेखण";
+"docs.editor.toolbar.group.lists" = "सूचियाँ";
+"docs.editor.inspector.label" = "फ़ॉर्मैट";
+"docs.editor.inspector.toggle" = "फ़ॉर्मैट";
+"docs.share.action" = "शेयर करें…";
+"native.subtitle.saved" = "सेव हो गया";
+"native.subtitle.viewOnly" = "सिर्फ़ देखने के लिए";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "अब उपलब्ध नहीं";
+"native.unavailable.body" = "यह दस्तावेज़ मिटा दिया गया है या अब आपके साथ शेयर नहीं है।";
+"native.subtitle.signedOut" = "साइन आउट हो गया";
+"native.format.show" = "फ़ॉर्मैट दिखाएँ";
+"native.format.hide" = "फ़ॉर्मैट छिपाएँ";
diff --git a/native/apple/Sources/DocsKit/Resources/hi.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/hi.lproj/Mac.strings
index 3919264..9ed1825 100644
--- a/native/apple/Sources/DocsKit/Resources/hi.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/hi.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "खाते";
"Actual size" = "वास्तविक आकार";
-"Alignment" = "संरेखण";
-"Block quote" = "ब्लॉक उद्धरण";
-"Bold" = "बोल्ड";
-"Bullet list" = "बुलेट वाली सूची";
"Cell contents" = "सेल की सामग्री";
-"Clear formatting" = "फ़ॉर्मैटिंग हटाएँ";
"Close this account’s document windows before signing out." = "साइन आउट करने से पहले इस खाते की दस्तावेज़ विंडो बंद करें।";
"Create a document to get started." = "आपके बनाए दस्तावेज़ यहाँ दिखेंगे, सबसे नए पहले।";
"Docs" = "Docs";
-"Document" = "दस्तावेज़";
-"Document inspector" = "दस्तावेज़ निरीक्षक";
"Double-click to fit column to contents" = "सामग्री के अनुसार आकार बदलने के लिए डबल-क्लिक करें";
"Edit %@" = "%@ संपादित करें";
"Export" = "निर्यात";
"Fit column to contents" = "सामग्री के अनुसार स्तंभ का आकार बदलें";
-"Font" = "फ़ॉन्ट";
-"Format" = "फ़ॉर्मैट";
"Heading %d" = "शीर्षक %d";
"Home" = "होम";
-"Indent" = "इंडेंट बढ़ाएँ";
-"Inline code" = "कोड";
-"Inspector" = "दस्तावेज़ निरीक्षक";
-"Italic" = "इटैलिक";
"Markdown…" = "Markdown";
"New document" = "नया दस्तावेज़";
"No documents" = "अभी कोई दस्तावेज़ नहीं";
"No recent documents" = "अभी कोई दस्तावेज़ नहीं";
-"Normal" = "मुख्य पाठ";
-"Numbered list" = "क्रमांकित सूची";
"Open a document from Home" = "होम से दस्तावेज़ खोलें";
-"Outdent" = "इंडेंट घटाएँ";
"PDF…" = "PDF";
-"Pages" = "पृष्ठों में";
-"Paragraph style" = "अनुच्छेद शैली";
"Print…" = "प्रिंट करें";
"Recent" = "हाल के";
"Recent documents" = "हाल के दस्तावेज़";
@@ -43,9 +25,7 @@
"Select column %@" = "स्तंभ %@ चुनें";
"Select row %d" = "पंक्ति %d चुनें";
"Shared" = "आपके साथ शेयर किए गए";
-"Share…" = "शेयर करें";
"Sign out" = "साइन आउट करें";
-"Size" = "आकार";
"Zoom" = "ज़ूम";
"Untitled document" = "बिना शीर्षक का दस्तावेज़";
diff --git a/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
index 5e26a65..94fda3f 100644
--- a/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "サインイン…";
"native.leave.sending" = "Docs はまだ変更を送信中です。保存されてからもう一度お試しください。";
"native.leave.openDocuments" = "先にこのアカウントの開いている書類を閉じてください。";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "履歴";
+"docs.editor.toolbar.group.style" = "スタイル";
+"docs.editor.toolbar.group.text" = "テキスト";
+"docs.editor.toolbar.group.align" = "配置";
+"docs.editor.toolbar.group.lists" = "リスト";
+"docs.editor.inspector.label" = "書式";
+"docs.editor.inspector.toggle" = "書式";
+"docs.share.action" = "共有…";
+"native.subtitle.saved" = "保存済み";
+"native.subtitle.viewOnly" = "閲覧のみ";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "利用できなくなりました";
+"native.unavailable.body" = "このドキュメントは削除されたか、共有が解除されました。";
+"native.subtitle.signedOut" = "サインアウト済み";
+"native.format.show" = "書式を表示";
+"native.format.hide" = "書式を隠す";
diff --git a/native/apple/Sources/DocsKit/Resources/ja.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/ja.lproj/Mac.strings
index 1b9af06..ad9ff50 100644
--- a/native/apple/Sources/DocsKit/Resources/ja.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/ja.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "アカウント";
"Actual size" = "実際のサイズ";
-"Alignment" = "配置";
-"Block quote" = "引用ブロック";
-"Bold" = "太字";
-"Bullet list" = "箇条書き";
"Cell contents" = "セルの内容";
-"Clear formatting" = "書式をクリア";
"Close this account’s document windows before signing out." = "サインアウトする前に、このアカウントの書類ウインドウを閉じてください。";
"Create a document to get started." = "作成したドキュメントが新しい順にここに表示されます。";
"Docs" = "Docs";
-"Document" = "書類";
-"Document inspector" = "書類インスペクタ";
"Double-click to fit column to contents" = "ダブルクリックで列幅を内容に合わせる";
"Edit %@" = "%@ を編集";
"Export" = "書き出す";
"Fit column to contents" = "列幅を内容に合わせる";
-"Font" = "フォント";
-"Format" = "書式";
"Heading %d" = "見出し %d";
"Home" = "ホーム";
-"Indent" = "インデントを増やす";
-"Inline code" = "コード";
-"Inspector" = "書類インスペクタ";
-"Italic" = "斜体";
"Markdown…" = "Markdown";
"New document" = "新規ドキュメント";
"No documents" = "ドキュメントはまだありません";
"No recent documents" = "ドキュメントはまだありません";
-"Normal" = "本文";
-"Numbered list" = "番号付きリスト";
"Open a document from Home" = "ホームから書類を開く";
-"Outdent" = "インデントを減らす";
"PDF…" = "PDF";
-"Pages" = "ページ区切り";
-"Paragraph style" = "段落スタイル";
"Print…" = "プリント";
"Recent" = "最近使った項目";
"Recent documents" = "最近の書類";
@@ -43,9 +25,7 @@
"Select column %@" = "列 %@ を選択";
"Select row %d" = "行 %d を選択";
"Shared" = "あなたと共有";
-"Share…" = "共有";
"Sign out" = "サインアウト";
-"Size" = "サイズ";
"Zoom" = "ズーム";
"Untitled document" = "無題のドキュメント";
diff --git a/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
index 2879eac..71b299a 100644
--- a/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "Iniciar sessão…";
"native.leave.sending" = "O Docs ainda está a enviar alterações. Tente de novo quando estiverem guardadas.";
"native.leave.openDocuments" = "Feche primeiro os documentos abertos desta conta.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "Histórico";
+"docs.editor.toolbar.group.style" = "Estilo";
+"docs.editor.toolbar.group.text" = "Texto";
+"docs.editor.toolbar.group.align" = "Alinhamento";
+"docs.editor.toolbar.group.lists" = "Listas";
+"docs.editor.inspector.label" = "Formato";
+"docs.editor.inspector.toggle" = "Formato";
+"docs.share.action" = "Partilhar…";
+"native.subtitle.saved" = "Guardado";
+"native.subtitle.viewOnly" = "Só leitura";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "Já não está disponível";
+"native.unavailable.body" = "Este documento foi eliminado ou já não está partilhado consigo.";
+"native.subtitle.signedOut" = "Sessão terminada";
+"native.format.show" = "Mostrar Formato";
+"native.format.hide" = "Ocultar Formato";
diff --git a/native/apple/Sources/DocsKit/Resources/pt.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/pt.lproj/Mac.strings
index a859c91..c037529 100644
--- a/native/apple/Sources/DocsKit/Resources/pt.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/pt.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Contas";
"Actual size" = "Tamanho real";
-"Alignment" = "Alinhamento";
-"Block quote" = "Citação em bloco";
-"Bold" = "Negrito";
-"Bullet list" = "Lista com marcas";
"Cell contents" = "Conteúdo da célula";
-"Clear formatting" = "Limpar formatação";
"Close this account’s document windows before signing out." = "Feche as janelas de documentos desta conta antes de terminar a sessão.";
"Create a document to get started." = "Os documentos que criar aparecem aqui, começando pelos mais recentes.";
"Docs" = "Docs";
-"Document" = "Documento";
-"Document inspector" = "Inspetor do documento";
"Double-click to fit column to contents" = "Clique duas vezes para ajustar a coluna ao conteúdo";
"Edit %@" = "Editar %@";
"Export" = "Exportar";
"Fit column to contents" = "Ajustar coluna ao conteúdo";
-"Font" = "Tipo de letra";
-"Format" = "Formato";
"Heading %d" = "Título %d";
"Home" = "Início";
-"Indent" = "Aumentar avanço";
-"Inline code" = "Código";
-"Inspector" = "Inspetor do documento";
-"Italic" = "Itálico";
"Markdown…" = "Markdown";
"New document" = "Novo documento";
"No documents" = "Ainda não há documentos";
"No recent documents" = "Ainda não há documentos";
-"Normal" = "Corpo do texto";
-"Numbered list" = "Lista numerada";
"Open a document from Home" = "Abra um documento no Início";
-"Outdent" = "Diminuir avanço";
"PDF…" = "PDF";
-"Pages" = "Paginado";
-"Paragraph style" = "Estilo de parágrafo";
"Print…" = "Imprimir";
"Recent" = "Recentes";
"Recent documents" = "Documentos recentes";
@@ -43,9 +25,7 @@
"Select column %@" = "Selecionar coluna %@";
"Select row %d" = "Selecionar linha %d";
"Shared" = "Partilhados consigo";
-"Share…" = "Partilhar";
"Sign out" = "Terminar sessão";
-"Size" = "Tamanho";
"Zoom" = "Zoom";
"Untitled document" = "Documento sem título";
diff --git a/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
index 980a775..1ad2318 100644
--- a/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "Войти…";
"native.leave.sending" = "Docs ещё отправляет изменения. Повторите попытку, когда они сохранятся.";
"native.leave.openDocuments" = "Сначала закройте открытые документы этой учётной записи.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "История";
+"docs.editor.toolbar.group.style" = "Стиль";
+"docs.editor.toolbar.group.text" = "Текст";
+"docs.editor.toolbar.group.align" = "Выравнивание";
+"docs.editor.toolbar.group.lists" = "Списки";
+"docs.editor.inspector.label" = "Формат";
+"docs.editor.inspector.toggle" = "Формат";
+"docs.share.action" = "Поделиться…";
+"native.subtitle.saved" = "Сохранено";
+"native.subtitle.viewOnly" = "Только просмотр";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "Больше недоступен";
+"native.unavailable.body" = "Этот документ удалён или больше не доступен вам.";
+"native.subtitle.signedOut" = "Вы вышли";
+"native.format.show" = "Показать панель «Формат»";
+"native.format.hide" = "Скрыть панель «Формат»";
diff --git a/native/apple/Sources/DocsKit/Resources/ru.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/ru.lproj/Mac.strings
index 83aa91e..a33de18 100644
--- a/native/apple/Sources/DocsKit/Resources/ru.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/ru.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Учётные записи";
"Actual size" = "Фактический размер";
-"Alignment" = "Выравнивание";
-"Block quote" = "Блок цитаты";
-"Bold" = "Полужирный";
-"Bullet list" = "Маркированный список";
"Cell contents" = "Содержимое ячейки";
-"Clear formatting" = "Очистить форматирование";
"Close this account’s document windows before signing out." = "Перед выходом закройте окна документов этой учётной записи.";
"Create a document to get started." = "Созданные вами документы появятся здесь, начиная с самых новых.";
"Docs" = "Docs";
-"Document" = "Документ";
-"Document inspector" = "Инспектор документа";
"Double-click to fit column to contents" = "Дважды щёлкните для подгонки ширины столбца";
"Edit %@" = "Изменить %@";
"Export" = "Экспорт";
"Fit column to contents" = "Подогнать ширину столбца";
-"Font" = "Шрифт";
-"Format" = "Формат";
"Heading %d" = "Заголовок %d";
"Home" = "Главная";
-"Indent" = "Увеличить отступ";
-"Inline code" = "Код";
-"Inspector" = "Инспектор документа";
-"Italic" = "Курсив";
"Markdown…" = "Markdown";
"New document" = "Новый документ";
"No documents" = "Документов пока нет";
"No recent documents" = "Документов пока нет";
-"Normal" = "Основной текст";
-"Numbered list" = "Нумерованный список";
"Open a document from Home" = "Откройте документ на главной";
-"Outdent" = "Уменьшить отступ";
"PDF…" = "PDF";
-"Pages" = "Постраничный";
-"Paragraph style" = "Стиль абзаца";
"Print…" = "Печать";
"Recent" = "Недавние";
"Recent documents" = "Недавние документы";
@@ -43,9 +25,7 @@
"Select column %@" = "Выбрать столбец %@";
"Select row %d" = "Выбрать строку %d";
"Shared" = "Доступные вам";
-"Share…" = "Поделиться";
"Sign out" = "Выйти";
-"Size" = "Размер";
"Zoom" = "Масштаб";
"Untitled document" = "Документ без названия";
diff --git a/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
index 6584734..d631de4 100644
--- a/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "Đăng nhập…";
"native.leave.sending" = "Docs vẫn đang gửi các thay đổi. Hãy thử lại khi chúng đã được lưu.";
"native.leave.openDocuments" = "Hãy đóng các tài liệu đang mở của tài khoản này trước.";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "Lịch sử";
+"docs.editor.toolbar.group.style" = "Kiểu";
+"docs.editor.toolbar.group.text" = "Văn bản";
+"docs.editor.toolbar.group.align" = "Căn lề";
+"docs.editor.toolbar.group.lists" = "Danh sách";
+"docs.editor.inspector.label" = "Định dạng";
+"docs.editor.inspector.toggle" = "Định dạng";
+"docs.share.action" = "Chia sẻ…";
+"native.subtitle.saved" = "Đã lưu";
+"native.subtitle.viewOnly" = "Chỉ xem";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "Không còn khả dụng";
+"native.unavailable.body" = "Tài liệu này đã bị xóa hoặc không còn được chia sẻ với bạn.";
+"native.subtitle.signedOut" = "Đã đăng xuất";
+"native.format.show" = "Hiện Định dạng";
+"native.format.hide" = "Ẩn Định dạng";
diff --git a/native/apple/Sources/DocsKit/Resources/vi.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/vi.lproj/Mac.strings
index fb823d0..ad1b733 100644
--- a/native/apple/Sources/DocsKit/Resources/vi.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/vi.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "Tài khoản";
"Actual size" = "Kích thước thực";
-"Alignment" = "Căn chỉnh";
-"Block quote" = "Khối trích dẫn";
-"Bold" = "Đậm";
-"Bullet list" = "Danh sách dấu đầu dòng";
"Cell contents" = "Nội dung ô";
-"Clear formatting" = "Xóa định dạng";
"Close this account’s document windows before signing out." = "Đóng các cửa sổ tài liệu của tài khoản này trước khi đăng xuất.";
"Create a document to get started." = "Tài liệu bạn tạo sẽ xuất hiện ở đây, mới nhất trước.";
"Docs" = "Docs";
-"Document" = "Tài liệu";
-"Document inspector" = "Thuộc tính tài liệu";
"Double-click to fit column to contents" = "Nhấp đúp để khớp cột với nội dung";
"Edit %@" = "Sửa %@";
"Export" = "Xuất";
"Fit column to contents" = "Khớp cột với nội dung";
-"Font" = "Phông chữ";
-"Format" = "Định dạng";
"Heading %d" = "Tiêu đề %d";
"Home" = "Trang chủ";
-"Indent" = "Tăng thụt lề";
-"Inline code" = "Mã";
-"Inspector" = "Thuộc tính tài liệu";
-"Italic" = "Nghiêng";
"Markdown…" = "Markdown";
"New document" = "Tài liệu mới";
"No documents" = "Chưa có tài liệu";
"No recent documents" = "Chưa có tài liệu";
-"Normal" = "Văn bản nội dung";
-"Numbered list" = "Danh sách đánh số";
"Open a document from Home" = "Mở tài liệu từ Trang chủ";
-"Outdent" = "Giảm thụt lề";
"PDF…" = "PDF";
-"Pages" = "Theo trang";
-"Paragraph style" = "Kiểu đoạn văn";
"Print…" = "In";
"Recent" = "Gần đây";
"Recent documents" = "Tài liệu gần đây";
@@ -43,9 +25,7 @@
"Select column %@" = "Chọn cột %@";
"Select row %d" = "Chọn hàng %d";
"Shared" = "Được chia sẻ với bạn";
-"Share…" = "Chia sẻ";
"Sign out" = "Đăng xuất";
-"Size" = "Kích cỡ";
"Zoom" = "Thu phóng";
"Untitled document" = "Tài liệu chưa đặt tên";
diff --git a/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
index d5f470a..04dc668 100644
--- a/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "登入…";
"native.leave.sending" = "Docs 仲傳緊啲改動。儲存好之後再試吓。";
"native.leave.openDocuments" = "請先閂咗呢個帳戶開緊嘅文件。";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "記錄";
+"docs.editor.toolbar.group.style" = "樣式";
+"docs.editor.toolbar.group.text" = "文字";
+"docs.editor.toolbar.group.align" = "對齊";
+"docs.editor.toolbar.group.lists" = "清單";
+"docs.editor.inspector.label" = "格式";
+"docs.editor.inspector.toggle" = "格式";
+"docs.share.action" = "分享…";
+"native.subtitle.saved" = "已儲存";
+"native.subtitle.viewOnly" = "只可以睇";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "已經冇得用";
+"native.unavailable.body" = "呢份文件已經刪除咗,或者冇再同你分享。";
+"native.subtitle.signedOut" = "已經登出";
+"native.format.show" = "顯示格式";
+"native.format.hide" = "隱藏格式";
diff --git a/native/apple/Sources/DocsKit/Resources/yue.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/yue.lproj/Mac.strings
index 2657f81..08dc626 100644
--- a/native/apple/Sources/DocsKit/Resources/yue.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/yue.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "帳戶";
"Actual size" = "實際大小";
-"Alignment" = "對齊";
-"Block quote" = "引文區塊";
-"Bold" = "粗體";
-"Bullet list" = "項目符號清單";
"Cell contents" = "儲存格內容";
-"Clear formatting" = "清除格式";
"Close this account’s document windows before signing out." = "登出前請先關閉此帳戶嘅文件視窗。";
"Create a document to get started." = "你建立嘅文件會喺呢度顯示,最新嘅排最前。";
"Docs" = "Docs";
-"Document" = "文件";
-"Document inspector" = "文件檢查器";
"Double-click to fit column to contents" = "按兩下以按內容調整欄寬";
"Edit %@" = "編輯 %@";
"Export" = "輸出";
"Fit column to contents" = "按內容調整欄寬";
-"Font" = "字體";
-"Format" = "格式";
"Heading %d" = "標題 %d";
"Home" = "主頁";
-"Indent" = "增加縮排";
-"Inline code" = "程式碼";
-"Inspector" = "文件檢查器";
-"Italic" = "斜體";
"Markdown…" = "Markdown";
"New document" = "新增文件";
"No documents" = "仲未有文件";
"No recent documents" = "仲未有文件";
-"Normal" = "內文";
-"Numbered list" = "編號清單";
"Open a document from Home" = "由主頁開啟文件";
-"Outdent" = "減少縮排";
"PDF…" = "PDF";
-"Pages" = "分頁";
-"Paragraph style" = "段落樣式";
"Print…" = "列印";
"Recent" = "最近項目";
"Recent documents" = "最近文件";
@@ -43,9 +25,7 @@
"Select column %@" = "選取 %@ 欄";
"Select row %d" = "選取第 %d 行";
"Shared" = "同你分享嘅文件";
-"Share…" = "分享";
"Sign out" = "登出";
-"Size" = "大小";
"Zoom" = "縮放";
"Untitled document" = "未命名文件";
diff --git a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
index 2f929b0..76610d3 100644
--- a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
@@ -205,3 +205,21 @@
"native.settings.signIn" = "登录…";
"native.leave.sending" = "Docs 仍在发送更改。保存后请重试。";
"native.leave.openDocuments" = "请先关闭此账户中打开的文档。";
+
+/* S2a: the Mac document window's header, subtitle and Format inspector (spec 2026-11-22 §1, §6, §8). */
+"docs.editor.toolbar.history" = "历史记录";
+"docs.editor.toolbar.group.style" = "样式";
+"docs.editor.toolbar.group.text" = "文本";
+"docs.editor.toolbar.group.align" = "对齐";
+"docs.editor.toolbar.group.lists" = "列表";
+"docs.editor.inspector.label" = "格式";
+"docs.editor.inspector.toggle" = "格式";
+"docs.share.action" = "共享…";
+"native.subtitle.saved" = "已保存";
+"native.subtitle.viewOnly" = "仅查看";
+"native.subtitle.joined" = "%1$@ · %2$@";
+"native.subtitle.unavailable" = "已不可用";
+"native.unavailable.body" = "此文档已被删除,或不再与您共享。";
+"native.subtitle.signedOut" = "已退出登录";
+"native.format.show" = "显示格式";
+"native.format.hide" = "隐藏格式";
diff --git a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Mac.strings b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Mac.strings
index 6db2e5c..e5abdb6 100644
--- a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Mac.strings
+++ b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Mac.strings
@@ -1,39 +1,21 @@
"Accounts" = "账户";
"Actual size" = "实际大小";
-"Alignment" = "对齐";
-"Block quote" = "块引用";
-"Bold" = "粗体";
-"Bullet list" = "项目符号列表";
"Cell contents" = "单元格内容";
-"Clear formatting" = "清除格式";
"Close this account’s document windows before signing out." = "退出登录前请关闭此账户的文档窗口。";
"Create a document to get started." = "您创建的文档会显示在这里,最新的排在最前面。";
"Docs" = "Docs";
-"Document" = "文档";
-"Document inspector" = "文档检查器";
"Double-click to fit column to contents" = "双击以根据内容调整列宽";
"Edit %@" = "编辑 %@";
"Export" = "导出";
"Fit column to contents" = "根据内容调整列宽";
-"Font" = "字体";
-"Format" = "格式";
"Heading %d" = "标题 %d";
"Home" = "主页";
-"Indent" = "增加缩进";
-"Inline code" = "代码";
-"Inspector" = "文档检查器";
-"Italic" = "斜体";
"Markdown…" = "Markdown";
"New document" = "新建文档";
"No documents" = "还没有文档";
"No recent documents" = "还没有文档";
-"Normal" = "正文";
-"Numbered list" = "编号列表";
"Open a document from Home" = "从主页打开文档";
-"Outdent" = "减少缩进";
"PDF…" = "PDF";
-"Pages" = "分页";
-"Paragraph style" = "段落样式";
"Print…" = "打印";
"Recent" = "最近项目";
"Recent documents" = "最近文档";
@@ -43,9 +25,7 @@
"Select column %@" = "选择 %@ 列";
"Select row %d" = "选择第 %d 行";
"Shared" = "与您共享";
-"Share…" = "共享";
"Sign out" = "退出登录";
-"Size" = "大小";
"Zoom" = "缩放";
"Untitled document" = "无标题文档";