diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index af1b6c862..4dce8a239 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,6 +13,7 @@ This release starts moving types and views that relate to other types into the t ### ✨ Features * `RichTextAlignment.Picker` has a new style parameter. +* `RichTextCommand` is a new namespace for command-related views. ### 🗑️ Deprecations @@ -23,6 +24,7 @@ This release starts moving types and views that relate to other types into the t * `RichTextArgumentReader` deprecates the font name and size functions. * `RichTextArgumentWriter` deprecates the font name and size functions. * `RichTextColorPicker` has been renamed to `RichTextColor.Picker`. +* `RichTextCommand` views are now nested within the new `RichTextCommand` type. * `RichTextComponent` deprecates the font name and size functions. diff --git a/Sources/RichTextKit/Commands/RichTextCommand+ActionButton.swift b/Sources/RichTextKit/Commands/RichTextCommand+ActionButton.swift new file mode 100644 index 000000000..9b2d1d412 --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+ActionButton.swift @@ -0,0 +1,53 @@ +// +// RichTextCommand+ActionButton.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-08. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This button can be used to trigger any ``RichTextAction`` + from a main menu command item. + + This button gets ``RichTextContext`` as a focused value. + It will be nil if no view has focus, which will disable + the button altogether. + */ + struct ActionButton: View { + + /** + Create a command button. + + - Parameters: + - action: The action to trigger. + */ + public init( + action: RichTextAction + ) { + self.action = action + } + + private let action: RichTextAction + + @FocusedValue(\.richTextContext) + private var context: RichTextContext? + + public var body: some View { + SwiftUI.Button(action.menuTitle) { + context?.handle(action) + } + .disabled(!canHandle) + .keyboardShortcut(for: action) + .accessibilityLabel(action.title) + } + + private var canHandle: Bool { + context?.canHandle(action) ?? false + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand+ActionButtonGroup.swift b/Sources/RichTextKit/Commands/RichTextCommand+ActionButtonGroup.swift new file mode 100644 index 000000000..a3b8851ca --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+ActionButtonGroup.swift @@ -0,0 +1,39 @@ +// +// RichTextCommand+ActionButtonGroup.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-08. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This view can be used to render a collection of actions + as main menu command items. + */ + struct ActionButtonGroup: View { + + /** + Create a command button group. + + - Parameters: + - actions: The actions to trigger. + */ + public init( + actions: [RichTextAction] + ) { + self.actions = actions + } + + private let actions: [RichTextAction] + + public var body: some View { + ForEach(actions) { + ActionButton(action: $0) + } + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand+AlignmentOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommand+AlignmentOptionsGroup.swift new file mode 100644 index 000000000..b59f8d6f4 --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+AlignmentOptionsGroup.swift @@ -0,0 +1,28 @@ +// +// RichTextCommand+AlignmentOptionsGroup.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This view renders ``RichTextAlignment`` command options. + */ + struct AlignmentOptionsGroup: View { + + public init() {} + + public var body: some View { + ActionButtonGroup( + actions: RichTextAlignment.allCases.map { + .setAlignment($0) + } + ) + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand+FontSizeOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommand+FontSizeOptionsGroup.swift new file mode 100644 index 000000000..f62fa8b10 --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+FontSizeOptionsGroup.swift @@ -0,0 +1,29 @@ +// +// RichTextCommand+FontSizeOptionsGroup.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This view renders font size command options. + */ + struct FontSizeOptionsGroup: View { + + public init() {} + + public var body: some View { + ActionButtonGroup( + actions: [ + .increaseFontSize(), + .decreaseFontSize() + ] + ) + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand+FormatMenu.swift b/Sources/RichTextKit/Commands/RichTextCommand+FormatMenu.swift new file mode 100644 index 000000000..24641a42e --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+FormatMenu.swift @@ -0,0 +1,46 @@ +// +// RichTextCommand+FormatMenu.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +#if iOS || macOS || os(visionOS) +import SwiftUI + +public extension RichTextCommand { + + /** + This menu can be used to add format-specific options to + the main menu bar. + */ + struct FormatMenu: Commands { + + /// Create a rich text format command menu. + public init() {} + + @FocusedValue(\.richTextContext) + private var context: RichTextContext? + + public var body: some Commands { + CommandMenu(RTKL10n.menuFormat.text) { + Group { + Menu(RTKL10n.menuFont.text) { + StyleOptionsGroup() + Divider() + FontSizeOptionsGroup() + } + Menu(RTKL10n.menuText.text) { + AlignmentOptionsGroup() + } + Menu(RTKL10n.menuIndent.text) { + IndentOptionsGroup() + } + } + .disabled(context == nil) + } + } + } +} +#endif diff --git a/Sources/RichTextKit/Commands/RichTextCommand+IndentOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommand+IndentOptionsGroup.swift new file mode 100644 index 000000000..e3b407e0b --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+IndentOptionsGroup.swift @@ -0,0 +1,27 @@ +// +// RichTextCommand+IndentOptionsGroup.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This view renders ``RichTextIndent`` command options. + */ + struct IndentOptionsGroup: View { + + public var body: some View { + ActionButtonGroup( + actions: [ + .increaseIndent(), + .decreaseIndent() + ] + ) + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand+ShareMenu.swift b/Sources/RichTextKit/Commands/RichTextCommand+ShareMenu.swift new file mode 100644 index 000000000..1f67f35c6 --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+ShareMenu.swift @@ -0,0 +1,149 @@ +// +// RichTextCommand+ShreMenu.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +#if iOS || macOS || os(visionOS) +import SwiftUI + +public extension RichTextCommand { + + /** + This menu can be used to add sharing-related options to + the main menu bar. + + The menu will try to add options for share, export, and + print, if applicable to the current platform. Selecting + an option will trigger a corresponding, provided action. + + The macOS exclusive `nsSharing` commands require you to + return a share url, after which a command takes care of + the sharing. Also note that the `formatNSSharingAction` + and `pdfNSSharingAction` will only have effect on macOS, + where they will add ``RichTextNSSharingMenu`` options. + + Note that a pdf action menu will only be included if it + has a corresponding action. Also note that you must use + `isEnabled: false` to disable the menu, since you can't + add `.disabled` to the command menu. + + Setting any action to nil removes a corrsponding option + from the menu. + */ + struct ShareMenu: Commands { + + /** + Create a rich text share command menu. + */ + public init( + isEnabled: Bool = true, + shareFormats: [RichTextDataFormat], + exportFormats: [RichTextDataFormat], + formatShareAction: FormatAction? = nil, + pdfShareAction: PdfAction? = nil, + formatNSSharingAction: FormatNSSharingAction? = nil, + pdfNSSharingAction: PdfNSSharingAction? = nil, + formatExportAction: FormatAction? = nil, + pdfExportAction: PdfAction? = nil, + printAction: PrintAction? = nil + ) { + self.isEnabled = isEnabled + self.shareFormats = shareFormats + self.exportFormats = exportFormats + self.formatShareAction = formatShareAction + self.pdfShareAction = pdfShareAction + self.formatNSSharingAction = formatNSSharingAction + self.pdfNSSharingAction = pdfNSSharingAction + self.formatExportAction = formatExportAction + self.pdfExportAction = pdfExportAction + self.printAction = printAction + } + + public typealias FormatAction = (RichTextDataFormat) -> Void + public typealias FormatNSSharingAction = (RichTextDataFormat) -> URL? + public typealias PdfAction = () -> Void + public typealias PdfNSSharingAction = () -> URL? + public typealias PrintAction = () -> Void + + private let shareFormats: [RichTextDataFormat] + private let exportFormats: [RichTextDataFormat] + + private let isEnabled: Bool + private let formatShareAction: FormatAction? + private let pdfShareAction: PdfAction? + private let formatNSSharingAction: FormatNSSharingAction? + private let pdfNSSharingAction: PdfNSSharingAction? + private let formatExportAction: FormatAction? + private let pdfExportAction: PdfAction? + private let printAction: PrintAction? + + public var body: some Commands { + CommandGroup(replacing: .importExport) { + Group { + nssharingMenu + shareMenu + exportMenu + printButton + }.disabled(!isEnabled) + } + } + } +} + +private extension RichTextCommand.ShareMenu { + + var hasExportFormats: Bool { !exportFormats.isEmpty } + + var hasShareFormats: Bool { !shareFormats.isEmpty } +} + +private extension RichTextCommand.ShareMenu { + + @ViewBuilder + var exportMenu: some View { + if hasExportFormats, let action = formatExportAction { + RichTextExportMenu( + formats: shareFormats, + formatAction: action, + pdfAction: pdfExportAction + ) + } + } + + @ViewBuilder + var printButton: some View { + if let action = printAction { + Button(action: action) { + Label(RTKL10n.menuPrint.text, .richTextActionPrint) + }.keyboardShortcut(for: .print) + } + } + + @ViewBuilder + var nssharingMenu: some View { + #if macOS + if hasShareFormats, let action = formatNSSharingAction { + RichTextNSSharingMenu( + formats: shareFormats, + formatAction: action, + pdfAction: pdfNSSharingAction + ) + } + #endif + } + + @ViewBuilder + var shareMenu: some View { + if hasShareFormats, let action = formatShareAction { + RichTextShareMenu( + formats: shareFormats, + formatAction: action, + pdfAction: pdfShareAction + ) + } + } +} +#endif diff --git a/Sources/RichTextKit/Commands/RichTextCommand+StyleOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommand+StyleOptionsGroup.swift new file mode 100644 index 000000000..52904e9bd --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand+StyleOptionsGroup.swift @@ -0,0 +1,28 @@ +// +// RichTextCommand+StyleOptionsGroup.swift +// RichTextKit +// +// Created by Daniel Saidi on 2022-12-20. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. +// + +import SwiftUI + +public extension RichTextCommand { + + /** + This view renders ``RichTextStyle`` command options. + */ + struct StyleOptionsGroup: View { + + public init() {} + + public var body: some View { + ActionButtonGroup( + actions: RichTextStyle.allCases.map { + .toggleStyle($0) + } + ) + } + } +} diff --git a/Sources/RichTextKit/Commands/RichTextCommand.swift b/Sources/RichTextKit/Commands/RichTextCommand.swift new file mode 100644 index 000000000..e1a2b9a4e --- /dev/null +++ b/Sources/RichTextKit/Commands/RichTextCommand.swift @@ -0,0 +1,19 @@ +// +// RichTextCommands.swift +// RichTextKit +// +// Created by Daniel Saidi on 2024-01-18. +// Copyright © 2024 Daniel Saidi. All rights reserved. +// + +import Foundation + +/** + This type is used as a namespace for command-specific types, + like views that are to be added to the main menu bar. + + > Important: Most rich text commands require that there's a + focused ``RichTextContext`` value in the view hierarchy. If + not, they will be disabled. + */ +public struct RichTextCommand {} diff --git a/Sources/RichTextKit/Commands/RichTextCommandButton.swift b/Sources/RichTextKit/Commands/RichTextCommandButton.swift deleted file mode 100644 index 5b656118d..000000000 --- a/Sources/RichTextKit/Commands/RichTextCommandButton.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// RichTextCommandButton.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-08. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -/** - This button can be used to trigger a ``RichTextAction``. - - This button gets the ``RichTextContext`` as a focused value. - - The button renders a plain `Button` with a title and action, - that is meant to be used in a `Commands` group and rendered - in the main menu. - */ -public struct RichTextCommandButton: View { - - /** - Create a rich text command button. - - - Parameters: - - action: The action to trigger. - */ - public init( - action: RichTextAction - ) { - self.action = action - } - - private let action: RichTextAction - - @FocusedValue(\.richTextContext) - private var context: RichTextContext? - - public var body: some View { - Button(action.menuTitle) { - context?.handle(action) - } - .disabled(!canHandle) - .keyboardShortcut(for: action) - .accessibilityLabel(action.title) - } - - private var canHandle: Bool { - context?.canHandle(action) ?? false - } -} - -public struct RichTextCommandButtonGroup: View { - - /** - Create a rich text command button group. - - - Parameters: - - actions: The actions to trigger. - */ - public init( - actions: [RichTextAction] - ) { - self.actions = actions - } - - private let actions: [RichTextAction] - - public var body: some View { - ForEach(actions) { - RichTextCommandButton(action: $0) - } - } -} diff --git a/Sources/RichTextKit/Commands/RichTextCommandsAlignmentOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommandsAlignmentOptionsGroup.swift deleted file mode 100644 index 7ae8c2e3f..000000000 --- a/Sources/RichTextKit/Commands/RichTextCommandsAlignmentOptionsGroup.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// RichTextCommandsAlignmentOptionsGroup.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -/** - This view defines `Commands` content for alignment options. - */ -public struct RichTextCommandsAlignmentOptionsGroup: View { - - public init() {} - - public var body: some View { - ForEach(RichTextAlignment.allCases) { - RichTextCommandButton( - action: .setAlignment($0) - ) - } - } -} diff --git a/Sources/RichTextKit/Commands/RichTextCommandsFontSizeOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommandsFontSizeOptionsGroup.swift deleted file mode 100644 index 58bb1a04e..000000000 --- a/Sources/RichTextKit/Commands/RichTextCommandsFontSizeOptionsGroup.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// RichTextCommandsFontSizeOptionsGroup.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -/** - This view defines `Commands` content for font size options. - */ -public struct RichTextCommandsFontSizeOptionsGroup: View { - - public init() {} - - @FocusedValue(\.richTextContext) - private var context: RichTextContext? - - public var body: some View { - RichTextCommandButtonGroup( - actions: [ - .increaseFontSize(), - .decreaseFontSize() - ] - ) - } -} diff --git a/Sources/RichTextKit/Commands/RichTextCommandsIndentOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommandsIndentOptionsGroup.swift deleted file mode 100644 index a08c9c44d..000000000 --- a/Sources/RichTextKit/Commands/RichTextCommandsIndentOptionsGroup.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// RichTextCommandsIndentOptionsGroup.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -/** - This view defines `Commands` content for indent options. - */ -public struct RichTextCommandsIndentOptionsGroup: View { - - @FocusedValue(\.richTextContext) - private var context: RichTextContext? - - public var body: some View { - RichTextCommandButtonGroup( - actions: [ - .increaseIndent(), - .decreaseIndent() - ] - ) - } -} diff --git a/Sources/RichTextKit/Commands/RichTextCommandsStyleOptionsGroup.swift b/Sources/RichTextKit/Commands/RichTextCommandsStyleOptionsGroup.swift deleted file mode 100644 index 89fac3c82..000000000 --- a/Sources/RichTextKit/Commands/RichTextCommandsStyleOptionsGroup.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// RichTextCommandsStyleOptionsGroup.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -/** - This view defines `Commands` content for text style options. - */ -public struct RichTextCommandsStyleOptionsGroup: View { - - public init() {} - - @FocusedValue(\.richTextContext) - private var context: RichTextContext? - - public var body: some View { - ForEach(RichTextStyle.allCases) { - RichTextCommandButton( - action: .toggleStyle($0) - ) - } - } -} diff --git a/Sources/RichTextKit/Commands/RichTextFormatCommandMenu.swift b/Sources/RichTextKit/Commands/RichTextFormatCommandMenu.swift deleted file mode 100644 index 8654f9587..000000000 --- a/Sources/RichTextKit/Commands/RichTextFormatCommandMenu.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// RichTextFormatCommandMenu.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -#if iOS || macOS || os(visionOS) -import SwiftUI - -/** - This command menu can be used to add rich text menu options - for text formatting to an app's menu bar. - - The commands will be disabled if there's no focus value for - a ``RichTextContext``. Make sure to add it to the editor to - make these commands work: - - ```swift - RichTextEditor(...) - .focusedValue(\.richTextContext, richTextContext) - ``` - */ -public struct RichTextFormatCommandMenu: Commands { - - /// Create a rich text format command menu. - public init() {} - - @FocusedValue(\.richTextContext) - private var context: RichTextContext? - - public var body: some Commands { - CommandMenu(RTKL10n.menuFormat.text) { - Group { - Menu(RTKL10n.menuFont.text) { - RichTextCommandsStyleOptionsGroup() - Divider() - RichTextCommandsFontSizeOptionsGroup() - } - Menu(RTKL10n.menuText.text) { - RichTextCommandsAlignmentOptionsGroup() - } - Menu(RTKL10n.menuIndent.text) { - RichTextCommandsIndentOptionsGroup() - } - }.disabled(context == nil) - } - } -} -#endif diff --git a/Sources/RichTextKit/Commands/RichTextShareCommandMenu.swift b/Sources/RichTextKit/Commands/RichTextShareCommandMenu.swift deleted file mode 100644 index e63f46b47..000000000 --- a/Sources/RichTextKit/Commands/RichTextShareCommandMenu.swift +++ /dev/null @@ -1,146 +0,0 @@ -// -// RichTextShareCommandMenu.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-12-20. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -#if iOS || macOS || os(visionOS) -import SwiftUI - -/** - This command menu can be used to add rich text menu options - for share, export and print to an app's menu bar. - - The menu includes sharing, exporting and printing. Clicking - an option will trigger custom actions that you provide. - - Regarding sharing, the macOS exclusive `nsSharing` commands - require you to return a share url, after which the commands - take care of the sharing. - - Note that a pdf action menu will only be included if it has - a corresponding action. You must also add `isEnabled: false` - to disable the menu, since you can't add `.disabled` to the - command menu. - - Setting an action to `nil` removes the option from the menu. - */ -public struct RichTextShareCommandMenu: Commands { - - /** - Create a rich text share command menu. - - Setting `formatNSSharingAction` and `pdfNSSharingAction` - will only have an effect on macOS and will then be used - to add a ``RichTextNSSharingMenu`` to this command menu. - */ - public init( - isEnabled: Bool = true, - shareFormats: [RichTextDataFormat], - exportFormats: [RichTextDataFormat], - formatShareAction: FormatAction? = nil, - pdfShareAction: PdfAction? = nil, - formatNSSharingAction: FormatNSSharingAction? = nil, - pdfNSSharingAction: PdfNSSharingAction? = nil, - formatExportAction: FormatAction? = nil, - pdfExportAction: PdfAction? = nil, - printAction: PrintAction? = nil - ) { - self.isEnabled = isEnabled - self.shareFormats = shareFormats - self.exportFormats = exportFormats - self.formatShareAction = formatShareAction - self.pdfShareAction = pdfShareAction - self.formatNSSharingAction = formatNSSharingAction - self.pdfNSSharingAction = pdfNSSharingAction - self.formatExportAction = formatExportAction - self.pdfExportAction = pdfExportAction - self.printAction = printAction - } - - public typealias FormatAction = (RichTextDataFormat) -> Void - public typealias FormatNSSharingAction = (RichTextDataFormat) -> URL? - public typealias PdfAction = () -> Void - public typealias PdfNSSharingAction = () -> URL? - public typealias PrintAction = () -> Void - - private let shareFormats: [RichTextDataFormat] - private let exportFormats: [RichTextDataFormat] - - private let isEnabled: Bool - private let formatShareAction: FormatAction? - private let pdfShareAction: PdfAction? - private let formatNSSharingAction: FormatNSSharingAction? - private let pdfNSSharingAction: PdfNSSharingAction? - private let formatExportAction: FormatAction? - private let pdfExportAction: PdfAction? - private let printAction: PrintAction? - - public var body: some Commands { - CommandGroup(replacing: .importExport) { - Group { - nssharingMenu - shareMenu - exportMenu - printButton - }.disabled(!isEnabled) - } - } -} - -private extension RichTextShareCommandMenu { - - var hasExportFormats: Bool { !exportFormats.isEmpty } - - var hasShareFormats: Bool { !shareFormats.isEmpty } -} - -private extension RichTextShareCommandMenu { - - @ViewBuilder - var exportMenu: some View { - if hasExportFormats, let action = formatExportAction { - RichTextExportMenu( - formats: shareFormats, - formatAction: action, - pdfAction: pdfExportAction - ) - } - } - - @ViewBuilder - var printButton: some View { - if let action = printAction { - Button(action: action) { - Label(RTKL10n.menuPrint.text, .richTextActionPrint) - }.keyboardShortcut(for: .print) - } - } - - @ViewBuilder - var nssharingMenu: some View { - #if macOS - if hasShareFormats, let action = formatNSSharingAction { - RichTextNSSharingMenu( - formats: shareFormats, - formatAction: action, - pdfAction: pdfNSSharingAction - ) - } - #endif - } - - @ViewBuilder - var shareMenu: some View { - if hasShareFormats, let action = formatShareAction { - RichTextShareMenu( - formats: shareFormats, - formatAction: action, - pdfAction: pdfShareAction - ) - } - } -} -#endif diff --git a/Sources/RichTextKit/RichTextKit.docc/RichTextKit.md b/Sources/RichTextKit/RichTextKit.docc/RichTextKit.md index 56ba2237c..f1173a73e 100644 --- a/Sources/RichTextKit/RichTextKit.docc/RichTextKit.md +++ b/Sources/RichTextKit/RichTextKit.docc/RichTextKit.md @@ -86,14 +86,7 @@ RichTextKit is available under the MIT license. See the [LICENSE][License] file ### Commands -- ``RichTextCommandButton`` -- ``RichTextCommandButtonGroup`` -- ``RichTextCommandsAlignmentOptionsGroup`` -- ``RichTextCommandsIndentOptionsGroup`` -- ``RichTextCommandsFontSizeOptionsGroup`` -- ``RichTextCommandsStyleOptionsGroup`` -- ``RichTextFormatCommandMenu`` -- ``RichTextShareCommandMenu`` +- ``RichTextCommand`` ### Data diff --git a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift index c97d8a136..f951c8dce 100644 --- a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift +++ b/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift @@ -4,7 +4,7 @@ import SwiftUI @available(*, deprecated, renamed: "RichTextColor.Picker") public typealias RichTextColorPicker = RichTextColor.Picker -public extension RichTextColorPicker { +public extension RichTextColor.Picker { @available(*, deprecated, renamed: "init(icon:value:showIcon:quickColors:)") init( @@ -76,7 +76,7 @@ public extension RichTextColorPicker { } } -public extension RichTextColorPicker { +public extension RichTextColor.Picker { @available(*, deprecated, message: "PickerColor is no longer used.") enum PickerColor: String, CaseIterable, Identifiable { diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift new file mode 100644 index 000000000..c4917f173 --- /dev/null +++ b/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift @@ -0,0 +1,26 @@ +import SwiftUI + +@available(*, deprecated, renamed: "RichTextCommand.ActionButton") +public typealias RichTextCommandButton = RichTextCommand.ActionButton + +@available(*, deprecated, renamed: "RichTextCommand.ActionButtonGroup") +public typealias RichTextCommandButtonGroup = RichTextCommand.ActionButtonGroup + +@available(*, deprecated, renamed: "RichTextCommand.AlignmentOptionsGroup") +public typealias RichTextCommandsAlignmentOptionsGroup = RichTextCommand.AlignmentOptionsGroup + +@available(*, deprecated, renamed: "RichTextCommand.FontSizeOptionsGroup") +public typealias RichTextCommandsFontSizeOptionsGroup = RichTextCommand.FontSizeOptionsGroup + +@available(*, deprecated, renamed: "RichTextCommand.IndentOptionsGroup") +public typealias RichTextCommandsIndentOptionsGroup = RichTextCommand.IndentOptionsGroup + +@available(*, deprecated, renamed: "RichTextCommand.StyleOptionsGroup") +public typealias RichTextCommandsStyleOptionsGroup = RichTextCommand.StyleOptionsGroup + +@available(*, deprecated, renamed: "RichTextCommand.FormatMenu") +public typealias RichTextFormatCommandMenu = RichTextCommand.FormatMenu + +@available(*, deprecated, renamed: "RichTextCommand.ShareMenu") +public typealias RichTextShareCommandMenu = RichTextCommand.ShareMenu +