| index d8e7059..a2e87b3 100644 |
| --- a/native/apple/Sources/DocsKit/DocsFormatInspector.swift |
| +++ b/native/apple/Sources/DocsKit/DocsFormatInspector.swift |
| @@ -113,12 +113,7 @@ import SwiftUI |
| /// 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: 13, heading: true))) |
| - } |
| + let entries = Self.styleEntries(selected: selection.style, strings: strings) |
| 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") } |
| @@ -135,6 +130,31 @@ import SwiftUI |
| .frame(minWidth: 0, maxWidth: .infinity) |
| } |
| |
| + /// Body text and Headings 1–3, each in its own face, and the selection's |
| + /// own level when it is in a Heading 4–6. |
| + static func styleEntries(selected: String, strings: DocsStrings) -> [DocsPopUp.Entry] { |
| + 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: 13, heading: true))) |
| + } |
| + // Headings 4–6 still render and edit but are not offered (spec §1, |
| + // menus). A selection in one shows its own level, never the style |
| + // the pop-up last showed. |
| + if selected.hasPrefix("heading"), let level = Int(selected.dropFirst("heading".count)), level > 3 { |
| + entries.append(.init(id: selected, title: Self.headingTitle(level, strings: strings), |
| + font: DocsFonts.font(marks: [:], size: 13, heading: true))) |
| + } |
| + return entries |
| + } |
| + |
| + /// "Heading 4" and so on, from the catalog's own format ("Heading %d"). |
| + static func headingTitle(_ level: Int, strings: DocsStrings) -> String { |
| + let format = strings.bundle.localizedString(forKey: "Heading %d", value: nil, table: "Mac") |
| + return String(format: format, level) |
| + } |
| + |
| 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) }, |