diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b9f739bca..f1f75d592 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -12,15 +12,14 @@ This release removes all deprecated code and cleans up the library somewhat. ### ✨ Features -* The new `richTextKeyboardToolbarConfig` view extension can be used to configure a `RichTextKeyboardToolbar`. -* The new `richTextKeyboardToolbarStyle` view extension can be used to style a `RichTextKeyboardToolbar`. +* The new `richTextKeyboardToolbarConfig` view extension can be used to configure the `RichTextKeyboardToolbar`. +* The new `richTextKeyboardToolbarStyle` view extension can be used to style the `RichTextKeyboardToolbar`. ### 💥 Breaking Changes * All previously deprecated code has been deleted. -* `RichTextKeyboardToolbar`'s `style` and `config` is now applied with view extensions instead of with the initializer. -* `RichTextKeyboardToolbar`'s `leadingActions` and `trailingActions` are now specified with the configuration instead of the initializer. +* `RichTextKeyboardToolbar` is now configured with view extensions instead of with the initializer. diff --git a/Sources/RichTextKit/Actions/RichTextAction.swift b/Sources/RichTextKit/Actions/RichTextAction.swift index 0fa93258e..53dbda1f2 100644 --- a/Sources/RichTextKit/Actions/RichTextAction.swift +++ b/Sources/RichTextKit/Actions/RichTextAction.swift @@ -89,13 +89,13 @@ public extension RichTextAction { /// The action's standard icon. var icon: Image { switch self { - case .copy: .richTextActionCopy - case .dismissKeyboard: .richTextActionDismissKeyboard + case .copy: .richTextCopy + case .dismissKeyboard: .richTextDismissKeyboard case .pasteImage: .richTextDocuments case .pasteImages: .richTextDocuments case .pasteText: .richTextDocuments - case .print: .richTextActionExport - case .redoLatestChange: .richTextActionRedo + case .print: .richTextPrint + case .redoLatestChange: .richTextRedo case .selectRange: .richTextSelection case .setAlignment(let val): val.icon case .setAttributedString: .richTextDocument @@ -108,7 +108,7 @@ public extension RichTextAction { case .stepLineSpacing: .richTextLineSpacing case .stepSuperscript(let val): .richTextStepSuperscript(val) case .toggleStyle(let val): val.icon - case .undoLatestChange: .richTextActionUndo + case .undoLatestChange: .richTextUndo } } diff --git a/Sources/RichTextKit/Data/RichTextDataFormat+Menu.swift b/Sources/RichTextKit/Data/RichTextDataFormat+Menu.swift index 984fb7c5b..955873d39 100644 --- a/Sources/RichTextKit/Data/RichTextDataFormat+Menu.swift +++ b/Sources/RichTextKit/Data/RichTextDataFormat+Menu.swift @@ -71,7 +71,7 @@ struct RichTextData_FormatMenu_Previews: PreviewProvider { VStack { RichTextDataFormat.Menu( title: "Export...", - icon: .richTextActionExport, + icon: .richTextExport, formatAction: { _ in }, pdfAction: {} ) diff --git a/Sources/RichTextKit/Export/RichTextExportMenu.swift b/Sources/RichTextKit/Export/RichTextExportMenu.swift index 01eb41363..57fa70e70 100644 --- a/Sources/RichTextKit/Export/RichTextExportMenu.swift +++ b/Sources/RichTextKit/Export/RichTextExportMenu.swift @@ -20,7 +20,7 @@ public struct RichTextExportMenu: View { public init( title: String = RTKL10n.menuExportAs.text, - icon: Image = .richTextActionExport, + icon: Image = .richTextExport, formats: [RichTextDataFormat] = RichTextDataFormat.libraryFormats, formatAction: @escaping (RichTextDataFormat) -> Void, pdfAction: (() -> Void)? = nil diff --git a/Sources/RichTextKit/Images/Image+RichText.swift b/Sources/RichTextKit/Images/Image+RichText.swift index 6daada8ed..bee7c2c37 100644 --- a/Sources/RichTextKit/Images/Image+RichText.swift +++ b/Sources/RichTextKit/Images/Image+RichText.swift @@ -10,14 +10,14 @@ import SwiftUI public extension Image { - static let richTextActionCopy = symbol("doc.on.clipboard") - static let richTextActionDismissKeyboard = symbol("keyboard.chevron.compact.down") - static let richTextActionEdit = symbol("square.and.pencil") - static let richTextActionExport = symbol("square.and.arrow.up.on.square") - static let richTextActionPrint = symbol("printer") - static let richTextActionRedo = symbol("arrow.uturn.forward") - static let richTextActionShare = symbol("square.and.arrow.up") - static let richTextActionUndo = symbol("arrow.uturn.backward") + static let richTextCopy = symbol("doc.on.clipboard") + static let richTextDismissKeyboard = symbol("keyboard.chevron.compact.down") + static let richTextEdit = symbol("square.and.pencil") + static let richTextExport = symbol("square.and.arrow.up.on.square") + static let richTextPrint = symbol("printer") + static let richTextRedo = symbol("arrow.uturn.forward") + static let richTextShare = symbol("square.and.arrow.up") + static let richTextUndo = symbol("arrow.uturn.backward") static let richTextAlignmentCenter = symbol("text.aligncenter") static let richTextAlignmentJustified = symbol("text.justify") diff --git a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Config.swift b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Config.swift new file mode 100644 index 000000000..67432a4e2 --- /dev/null +++ b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Config.swift @@ -0,0 +1,73 @@ +// +// RichTextKeyboardToolbar+Config.swift +// RichTextKit +// +// Created by Ryan Jarvis on 2024-02-24. +// + +#if iOS || macOS || os(visionOS) +import SwiftUI + +/// This struct can configure a ``RichTextKeyboardToolbar``. +public struct RichTextKeyboardToolbarConfig { + + /// Create a custom keyboard toolbar configuration. + /// + /// - Parameters: + /// - alwaysDisplayToolbar: Whether or not to always show the toolbar, by default `false`. + /// - leadingActions: The leading actions, by default `.undo` and `.redo`. + /// - trailingActions: The trailing actions, by default `.dismissKeyboard`. + public init( + alwaysDisplayToolbar: Bool = false, + leadingActions: [RichTextAction] = [.undo, .redo], + trailingActions: [RichTextAction] = [.dismissKeyboard] + ) { + self.alwaysDisplayToolbar = alwaysDisplayToolbar + self.leadingActions = leadingActions + self.trailingActions = trailingActions + } + + /// Whether or not to always show the toolbar. + public var alwaysDisplayToolbar: Bool + + /// The leading toolbar actions. + public var leadingActions: [RichTextAction] + + /// The trailing toolbar actions. + public var trailingActions: [RichTextAction] +} + +public extension RichTextKeyboardToolbarConfig { + + /// A standard rich text keyboard toolbar configuration. + /// + /// You can override this to change the global default. + static var standard = RichTextKeyboardToolbarConfig() +} + +public extension View { + + /// Apply a ``RichTextKeyboardToolbar`` configuration. + func richTextKeyboardToolbarConfig( + _ config: RichTextKeyboardToolbarConfig + ) -> some View { + self.environment(\.richTextKeyboardToolbarConfig, config) + } +} + +extension RichTextKeyboardToolbarConfig { + + struct Key: EnvironmentKey { + + public static var defaultValue: RichTextKeyboardToolbarConfig = .standard + } +} + +public extension EnvironmentValues { + + var richTextKeyboardToolbarConfig: RichTextKeyboardToolbarConfig { + get { self [RichTextKeyboardToolbarConfig.Key.self] } + set { self [RichTextKeyboardToolbarConfig.Key.self] = newValue } + } +} +#endif diff --git a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Configuration.swift b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Configuration.swift deleted file mode 100644 index 95c6aaaff..000000000 --- a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Configuration.swift +++ /dev/null @@ -1,61 +0,0 @@ -// -// RichTextKeyboardToolbar+Configuration.swift -// RichTextKit -// -// Created by Ryan Jarvis on 2024-02-24. -// - -#if iOS || macOS || os(visionOS) -import SwiftUI - -/// This struct can configure a ``RichTextKeyboardToolbar``. -public struct RichTextKeyboardToolbarConfiguration { - - /// Create a custom toolbar configuration. - /// - /// - Parameters: - /// - alwaysDisplayToolbar: Whether or not to always show the toolbar, by default `false`. - public init( - alwaysDisplayToolbar: Bool = false - ) { - self.alwaysDisplayToolbar = alwaysDisplayToolbar - } - - /// Whether or not to always show the toolbar - public var alwaysDisplayToolbar: Bool -} - -public extension RichTextKeyboardToolbarConfiguration { - - /// A standard rich text keyboard toolbar configuration. - /// - /// You can override this to change the global default. - static var standard = RichTextKeyboardToolbarConfiguration() -} - -public extension View { - - /// Apply a ``RichTextKeyboardToolbar`` configuration. - func richTextKeyboardToolbarConfiguration( - _ configuration: RichTextKeyboardToolbarConfiguration - ) -> some View { - self.environment(\.richTextKeyboardToolbarConfiguration, configuration) - } -} - -extension RichTextKeyboardToolbarConfiguration { - - struct Key: EnvironmentKey { - - public static var defaultValue: RichTextKeyboardToolbarConfiguration = .standard - } -} - -public extension EnvironmentValues { - - var richTextKeyboardToolbarConfiguration: RichTextKeyboardToolbarConfiguration { - get { self [RichTextKeyboardToolbarConfiguration.Key.self] } - set { self [RichTextKeyboardToolbarConfiguration.Key.self] = newValue } - } -} -#endif diff --git a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar.swift b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar.swift index bb65e89f6..8cb17ce0c 100644 --- a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar.swift +++ b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar.swift @@ -10,16 +10,11 @@ import SwiftUI /** - This toolbar can be added above the iOS keyboard to make it - easy to provide rich text formatting in a very compact form. + This toolbar can be added above an iOS keyboard, to provide + rich text formatting in a compact form. - This view has customizable actions and also supports adding - custom leading and trailing buttons. It shows more views if - the horizontal size class is regular. - - This custom toolbar is needed since ``RichTextEditor`` will - wrap a native `UIKit` text view, which means that using the - `toolbar` modifier with a `keyboard` placement doesn't work: + This toolbar is needed since the ``RichTextEditor`` can not + use a `toolbar` modifier with `.keyboard` placement: ```swift RichTextEditor(text: $text, context: context) @@ -29,11 +24,44 @@ import SwiftUI } } ``` - - The above code will simply not show anything when you start - to edit text. To work around this limitation, you can use a - this custom toolbar instead, which by default will show and - hide itself as you begin and end editing the text. + + Instead, add this toolbar below a ``RichTextEditor`` to let + it automatically show when the text editor is edited in iOS. + + You can inject additional leading and trailing buttons, and + customize the format sheet that is presented when users tap + format button: + + ```swift + VStack { + RichTextEditor(...) + RichTextKeyboardToolbar( + context: context, + leadingButtons: {}, + trailingButtons: {}, + formatSheet: { $0 } + ) + } + ``` + + These view builders provide you with standard views. Return + `$0` to use these standard views, or return any custom view + that you want to use instead. + + You can configure and style the view by applying config and + style view extensions to your view hierarchy: + + ```swift + VStack { + RichTextEditor(...) + RichTextKeyboardToolbar(...) + } + .richTextKeyboardToolbarStyle(...) + .richTextKeyboardToolbarConfig(...) + ``` + + For more information, see ``RichTextKeyboardToolbarConfig`` + and ``RichTextKeyboardToolbarStyle``. */ public struct RichTextKeyboardToolbar: View { @@ -42,34 +70,29 @@ public struct RichTextKeyboardToolbar LeadingButtons, - @ViewBuilder trailingButtons: @escaping () -> TrailingButtons, - @ViewBuilder formatSheet: @escaping (RichTextFormatSheet) -> FormatSheet + @ViewBuilder leadingButtons: @escaping (StandardLeadingButtons) -> LeadingButtons, + @ViewBuilder trailingButtons: @escaping (StandardTrailingButtons) -> TrailingButtons, + @ViewBuilder formatSheet: @escaping (StandardFormatSheet) -> FormatSheet ) { self._context = ObservedObject(wrappedValue: context) - self.leadingActions = leadingActions - self.trailingActions = trailingActions self.leadingButtons = leadingButtons self.trailingButtons = trailingButtons self.formatSheet = formatSheet } + + public typealias StandardLeadingButtons = EmptyView + public typealias StandardTrailingButtons = EmptyView + public typealias StandardFormatSheet = RichTextFormatSheet - private let leadingActions: [RichTextAction] - private let trailingActions: [RichTextAction] - - private let leadingButtons: () -> LeadingButtons - private let trailingButtons: () -> TrailingButtons - private let formatSheet: (RichTextFormatSheet) -> FormatSheet + private let leadingButtons: (StandardLeadingButtons) -> LeadingButtons + private let trailingButtons: (StandardTrailingButtons) -> TrailingButtons + private let formatSheet: (StandardFormatSheet) -> FormatSheet @ObservedObject private var context: RichTextContext @@ -80,11 +103,11 @@ public struct RichTextKeyboardToolbar: View { - /** - Create a keyboard toolbar menu. - */ + /// Create a keyboard toolbar menu. public init( @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: @escaping () -> Label diff --git a/Sources/RichTextKit/Sharing/RichTextShareMenu.swift b/Sources/RichTextKit/Sharing/RichTextShareMenu.swift index ea755ad6d..28eda9abf 100644 --- a/Sources/RichTextKit/Sharing/RichTextShareMenu.swift +++ b/Sources/RichTextKit/Sharing/RichTextShareMenu.swift @@ -23,7 +23,7 @@ public struct RichTextShareMenu: View { public init( title: String = RTKL10n.menuShareAs.text, - icon: Image = .richTextActionShare, + icon: Image = .richTextShare, formats: [RichTextDataFormat] = RichTextDataFormat.libraryFormats, formatAction: @escaping (RichTextDataFormat) -> Void, pdfAction: (() -> Void)? = nil diff --git a/Sources/RichTextKit/_Deprecated/RTKL10n+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RTKL10n+Deprecated.swift deleted file mode 100644 index 67bfe40f3..000000000 --- a/Sources/RichTextKit/_Deprecated/RTKL10n+Deprecated.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation - -@available(*, deprecated, message: "Use .module instead") -public extension RTKL10n { - - /** - The bundle to use to retrieve localized strings. - - You should only override this value when the entire set - of localized texts should be loaded from another bundle. - */ - static var bundle: Bundle = .module -} diff --git a/Sources/RichTextKit/_Deprecated/ReadersWriters+Deprecated.swift b/Sources/RichTextKit/_Deprecated/ReadersWriters+Deprecated.swift deleted file mode 100644 index 25b507bf7..000000000 --- a/Sources/RichTextKit/_Deprecated/ReadersWriters+Deprecated.swift +++ /dev/null @@ -1,175 +0,0 @@ -import Foundation - -@available(*, deprecated, message: "Use RichTextAttributeReader directly") -public protocol RichTextAlignmentReader: RichTextAttributeReader {} - -@available(*, deprecated, message: "Use RichTextAttributeWriter directly") -public protocol RichTextAlignmentWriter: RichTextAttributeWriter {} - -@available(*, deprecated, message: "Use RichTextAttributeReader directly") -public protocol RichTextColorWriter: RichTextAttributeWriter {} - -@available(*, deprecated, message: "Use RichTextAttributeWriter directly") -public protocol RichTextColorReader: RichTextAttributeReader {} - -@available(*, deprecated, message: "Use RichTextAttributeReader directly") -public protocol RichTextFontReader: RichTextAttributeReader {} - -@available(*, deprecated, message: "Use RichTextAttributeWriter directly") -public protocol RichTextFontWriter: RichTextAttributeReader, RichTextAttributeWriter {} - -@available(*, deprecated, message: "Use RichTextAttributeReader directly") -public protocol RichTextIndentReader: RichTextAttributeReader {} - -@available(*, deprecated, message: "Use RichTextAttributeWriter directly") -public protocol RichTextIndentWriter: RichTextAttributeWriter {} - -@available(*, deprecated, message: "Use RichTextAttributeReader directly") -public protocol RichTextStyleReader: RichTextAttributeReader {} - -@available(*, deprecated, message: "Use RichTextAttributeWriter directly") -public protocol RichTextStyleWriter: RichTextAttributeWriter, RichTextStyleReader {} - -public extension RichTextAttributeReader { - - @available(*, deprecated, renamed: "richTextBackgroundColor(at:)") - func backgroundColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.backgroundColor, at: range) - } - - @available(*, deprecated, renamed: "richTextForegroundColor(at:)") - func foregroundColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.foregroundColor, at: range) - } - - @available(*, deprecated, renamed: "richTextFont(at:)") - func font(at range: NSRange) -> FontRepresentable? { - richTextFont(at: range) - } - - @available(*, deprecated, renamed: "richTextAttribute(_:at:)") - func richTextFont( - at range: NSRange - ) -> FontRepresentable? { - richTextAttribute(.font, at: range) - } - - @available(*, deprecated, renamed: "richTextFontSize(at:)") - func fontSize(at range: NSRange) -> CGFloat? { - richTextFontSize(at: range) - } -} - -public extension RichTextAttributeWriter { - - @available(*, deprecated, renamed: "setRichTextBackgroundColor(_:at:)") - func setBackgroundColor( - to color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextBackgroundColor(color, at: range) - } - - @available(*, deprecated, renamed: "setFont(_:at:)") - func setFont( - to font: FontRepresentable, - at range: NSRange? = nil - ) { - setFont(font, at: range) - } - - @available(*, deprecated, renamed: "setFontName(_:at:)") - func setFontName( - to name: String, - at range: NSRange? = nil - ) { - setFontName(name, at: range) - } - - @available(*, deprecated, renamed: "setFontSize(_:at:)") - func setFontSize( - to size: CGFloat, - at range: NSRange? = nil - ) { - setFontSize(size, at: range) - } - - @available(*, deprecated, renamed: "setRichTextForegroundColor(_:at:)") - func setForegroundColor( - to color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextForegroundColor(color, at: range) - } - - @available(*, deprecated, renamed: "setRichTextAlignment(_:at:)") - func setRichTextAlignment( - to alignment: RichTextAlignment, - at range: NSRange - ) { - setRichTextAlignment(alignment, at: range) - } - - @available(*, deprecated, renamed: "setRichTextFont(_:at:)") - func setFont( - _ font: FontRepresentable, - at range: NSRange? = nil - ) { - setRichTextFont(font, at: range ?? richTextRange) - } - - @available(*, deprecated, renamed: "setRichTextFontName(_:at:)") - func setFontName( - _ name: String, - at range: NSRange? = nil - ) { - setRichTextFontName(name, at: range ?? richTextRange) - } - - @available(*, deprecated, renamed: "setRichTextFontSize(_:at:)") - func setFontSize( - _ size: CGFloat, - at range: NSRange? = nil - ) { - setRichTextFontSize(size, at: range ?? richTextRange) - } - - @available(*, deprecated, renamed: "stepRichTextIndent(_:at:)") - func setRichTextIndent( - to indent: RichTextIndent, - at range: NSRange - ) -> RichTextAttributes? { - let increase = indent == .increase - let change: CGFloat = 30.0 - let points = increase ? change : -change - return stepRichTextIndent(points: points, at: range) - } - - @available(*, deprecated, renamed: "stepRichTextFontSize(points:at:)") - func stepFontSize( - points: Int, - at range: NSRange - ) { - stepRichTextFontSize(points: points, at: range) - } - - @available(*, deprecated, message: "Use stepRichTextFontSize instead") - func decrementFontSize( - points: UInt = 1, - at range: NSRange - ) { - stepRichTextFontSize(points: -Int(points), at: range) - } - - @available(*, deprecated, message: "Use stepRichTextFontSize instead") - func incrementFontSize( - points: UInt = 1, - at range: NSRange - ) { - stepRichTextFontSize(points: Int(points), at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAction+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextAction+Deprecated.swift deleted file mode 100644 index fda097297..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAction+Deprecated.swift +++ /dev/null @@ -1,51 +0,0 @@ -import SwiftUI - -public extension RichTextAction { - - @available(*, deprecated, renamed: "increaseFontSize(points:)") - static var incrementFontSize: RichTextAction { stepFontSize(points: 1) } - - @available(*, deprecated, renamed: "decreaseFontSize(points:)") - static var decrementFontSize: RichTextAction { stepFontSize(points: -1) } - - @available(*, deprecated, renamed: "increaseFontSize(points:)") - static var increaseFontSize: RichTextAction { - increaseFontSize() - } - - @available(*, deprecated, renamed: "decreaseFontSize(points:)") - static var decreaseFontSize: RichTextAction { - decreaseFontSize() - } - - @available(*, deprecated, renamed: "increaseIndent(points:)") - static var increaseIndent: RichTextAction { - increaseIndent() - } - - @available(*, deprecated, renamed: "decreaseIndent(points:)") - static var decreaseIndent: RichTextAction { - decreaseIndent() - } - - @available(*, deprecated, renamed: "increaseSuperscript(steps:)") - static var increaseSuperscript: RichTextAction { - increaseSuperscript() - } - - @available(*, deprecated, renamed: "decreaseSuperscript(steps:)") - static var decreaseSuperscript: RichTextAction { - decreaseSuperscript() - } -} - -@available(*, deprecated, renamed: "RichTextAction.Button") -public typealias RichTextActionButton = RichTextAction.Button - -#if iOS || macOS || os(visionOS) -@available(*, deprecated, renamed: "RichTextAction.ButtonGroup") -public typealias RichTextActionButtonGroup = RichTextAction.ButtonGroup -#endif - -@available(*, deprecated, renamed: "RichTextAction.ButtonStack") -public typealias RichTextActionButtonStack = RichTextAction.ButtonStack diff --git a/Sources/RichTextKit/_Deprecated/RichTextAlignment+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextAlignment+Deprecated.swift deleted file mode 100644 index daa50b820..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAlignment+Deprecated.swift +++ /dev/null @@ -1,4 +0,0 @@ -import SwiftUI - -@available(*, deprecated, renamed: "RichTextAlignment.Picker") -public typealias RichTextAlignmentPicker = RichTextAlignment.Picker diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Alignment.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Alignment.swift deleted file mode 100644 index 908002a8c..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Alignment.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// RichTextAttributeReader+Alignment.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-29. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeReader { - - /// Get the rich text alignment at a certain range. - func richTextAlignment( - at range: NSRange - ) -> RichTextAlignment? { - let style = richTextParagraphStyle(at: range) - guard let style = style else { return nil } - return RichTextAlignment(style.alignment) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Colors.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Colors.swift deleted file mode 100644 index e89921814..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Colors.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// RichTextAttributeReader+Colors.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-30. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead") -public extension RichTextAttributeReader { - - /// Get a certain rich text color at a certain range. - func richTextColorOld( - _ color: RichTextColor, - at range: NSRange - ) -> ColorRepresentable? { - guard let attribute = color.attribute else { return nil } - return richTextAttribute(attribute, at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Deprecated.swift deleted file mode 100644 index aea9cf344..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Deprecated.swift +++ /dev/null @@ -1,53 +0,0 @@ -import Foundation - -public extension RichTextAttributeReader { - - @available(*, deprecated, message: "Use richTextFont(at:)?.fontName instead") - func richTextFontName( - at range: NSRange - ) -> String? { - richTextFont(at: range)?.fontName - } - - @available(*, deprecated, message: "Use richTextFont(at:)?.pointSize instead") - func richTextFontSize( - at range: NSRange - ) -> CGFloat? { - richTextFont(at: range)?.pointSize - } - - @available(*, deprecated, renamed: "richTextColor(_:at:)") - func richTextBackgroundColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.backgroundColor, at: range) - } - - @available(*, deprecated, renamed: "richTextColor(_:at:)") - func richTextForegroundColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.foregroundColor, at: range) - } - - @available(*, deprecated, renamed: "richTextColor(_:at:)") - func richTextStrikethroughColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.strikethroughColor, at: range) - } - - @available(*, deprecated, renamed: "richTextColor(_:at:)") - func richTextStrokeColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.strokeColor, at: range) - } - - @available(*, deprecated, renamed: "richTextColor(_:at:)") - func richTextUnderlineColor( - at range: NSRange - ) -> ColorRepresentable? { - richTextAttribute(.underlineColor, at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Indent.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Indent.swift deleted file mode 100644 index 246ef9295..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Indent.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// RichTextAttributeReader+Indent.swift -// RichTextKit -// -// Created by James Bradley on 2022-03-04. -// Copyright © 2023 James Bradley. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead") -public extension RichTextAttributeReader { - - /// Get the rich text indent at a certain range. - func richTextIndent( - at range: NSRange - ) -> CGFloat? { - let style = richTextParagraphStyle(at: range) - guard let style = style else { return nil } - return style.headIndent - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Paragraph.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Paragraph.swift deleted file mode 100644 index 9229ec494..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Paragraph.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// RichTextAttributeReader+Paragraph.swift -// RichTextKit -// -// Created by Daniel Saidi on 2023-10-17. -// Copyright © 2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -#if canImport(UIKit) -import UIKit -#endif - -#if canImport(AppKit) && !targetEnvironment(macCatalyst) -import AppKit -#endif - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeReader { - - /// Get the rich text paragraph style at a certain range. - func richTextParagraphStyle( - at range: NSRange - ) -> NSMutableParagraphStyle? { - richTextAttribute(.paragraphStyle, at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Style.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Style.swift deleted file mode 100644 index 24c91d6d9..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Style.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// RichTextAttributeReader+Style.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-28. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead") -public extension RichTextAttributeReader { - - /// Get all rich text styles at a certain range. - func richTextStyles( - at range: NSRange - ) -> [RichTextStyle] { - let attributes = richTextAttributes(at: range) - let traits = richTextFont(at: range)?.fontDescriptor.symbolicTraits - var styles = traits?.enabledRichTextStyles ?? [] - if attributes.isStrikethrough { styles.append(.strikethrough) } - if attributes.isUnderlined { styles.append(.underlined) } - return styles - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Superscript.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Superscript.swift deleted file mode 100644 index 73f3e8600..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeReader+Superscript.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// RichTextAttributeReader+Superscript.swift -// RichTextKit -// -// Created by Daniel Saidi on 2023-10-17. -// Copyright © 2023 Daniel Saidi. All rights reserved. -// - -#if macOS -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeReader { - - /// Get the superscript level at a certain range. - func richTextSuperscriptLevel( - at range: NSRange - ) -> Int? { - richTextAttribute(.superscript, at: range) - } -} -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Alignment.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Alignment.swift deleted file mode 100644 index e97d72406..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Alignment.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// RichTextAttributeWriter+Alignment.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-29. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -#if canImport(UIKit) -import UIKit -#endif - -#if canImport(AppKit) && !targetEnvironment(macCatalyst) -import AppKit -#endif - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeWriter { - - /// Set the rich text alignment at a certain range. - func setRichTextAlignment( - _ alignment: RichTextAlignment, - at range: NSRange - ) { - let paragraph = richTextParagraphStyle(at: range) ?? .init() - paragraph.alignment = alignment.nativeAlignment - setRichTextParagraphStyle(to: paragraph, at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+ColorDeprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+ColorDeprecated.swift deleted file mode 100644 index 2ea5746a6..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+ColorDeprecated.swift +++ /dev/null @@ -1,64 +0,0 @@ -import Foundation - -public extension RichTextAttributeWriter { - - @available(*, deprecated, renamed: "setRichTextColor(_:to:at:)") - func setRichTextBackgroundColor( - _ color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextAttribute( - .backgroundColor, - to: color, - at: range ?? richTextRange - ) - } - - @available(*, deprecated, renamed: "setRichTextColor(_:to:at:)") - func setRichTextForegroundColor( - _ color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextAttribute( - .foregroundColor, - to: color, - at: range ?? richTextRange - ) - } - - @available(*, deprecated, renamed: "setRichTextColor(_:to:at:)") - func setRichTextStrikethroughColor( - _ color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextAttribute( - .strikethroughColor, - to: color, - at: range ?? richTextRange - ) - } - - @available(*, deprecated, renamed: "setRichTextColor(_:to:at:)") - func setRichTextStrokeColor( - _ color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextAttribute( - .strokeColor, - to: color, - at: range ?? richTextRange - ) - } - - @available(*, deprecated, renamed: "setRichTextColor(_:to:at:)") - func setRichTextUnderlineColor( - _ color: ColorRepresentable, - at range: NSRange? = nil - ) { - setRichTextAttribute( - .underlineColor, - to: color, - at: range ?? richTextRange - ) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Colors.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Colors.swift deleted file mode 100644 index 4ba065e57..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Colors.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// RichTextAttributeWriter+Colors.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-30. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeWriter { - - /// Set a certain rich text color at a certain range. - func setRichTextColorOld( - _ color: RichTextColor, - to val: ColorRepresentable, - at range: NSRange - ) { - guard let attribute = color.attribute else { return } - if richTextColorOld(color, at: range) == val { return } - setRichTextAttribute(attribute, to: val, at: range) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Font.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Font.swift deleted file mode 100644 index cbb1e8350..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Font.swift +++ /dev/null @@ -1,95 +0,0 @@ -// -// RichTextAttributeWriter+Font.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-27. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeWriter { - - /// Set the rich text font at a certain range. - func setRichTextFont( - _ font: FontRepresentable, - at range: NSRange - ) { - setRichTextAttribute(.font, to: font, at: range) - } - - /// Set the rich text font name at a certain range. - /// - /// This may seem complicated, but so far it is the only - /// way that seems to work correctly. - /// - /// I previously grabbed the `typingAttributes` and took - /// the `.font` attribute from the dictionary, then took - /// its `fontDescriptor` and created a new font with the - /// `withFamily` function, then created a new font using - /// the new descriptor and the old font point size. - /// - /// However, that approach fails since the San Francisco - /// font specifies a certain usage, that causes the font - /// name to not apply. This code just creates a new font, - /// but be aware if something doesn't work as expected. - func setRichTextFontName( - _ name: String, - at range: NSRange - ) { - guard let text = mutableRichText else { return } - guard text.length > 0 else { return } - let fontName = settableFontName(for: name) - text.beginEditing() - text.enumerateAttribute(.font, in: range, options: .init()) { value, range, _ in - let oldFont = value as? FontRepresentable ?? .standardRichTextFont - let size = oldFont.pointSize - let newFont = FontRepresentable(name: fontName, size: size) ?? .standardRichTextFont - text.removeAttribute(.font, range: range) - text.addAttribute(.font, value: newFont, range: range) - text.fixAttributes(in: range) - } - text.endEditing() - } - - /// Set the rich text font size at a certain range. - func setRichTextFontSize( - _ size: CGFloat, - at range: NSRange - ) { - guard let text = mutableRichText else { return } - guard text.length > 0 else { return } - text.beginEditing() - text.enumerateAttribute(.font, in: range, options: .init()) { value, range, _ in - let oldFont = value as? FontRepresentable ?? .standardRichTextFont - let newFont = oldFont.withSize(size) - text.removeAttribute(.font, range: range) - text.addAttribute(.font, value: newFont, range: range) - text.fixAttributes(in: range) - } - text.endEditing() - } - - /// Step the rich text font size at a certain range. - func stepRichTextFontSize( - points: Int, - at range: NSRange - ) { - guard let size = richTextFont(at: range)?.pointSize else { return } - let newSize = size + CGFloat(points) - setRichTextFontSize(newSize, at: range) - } -} - -private extension RichTextAttributeWriter { - - /// We must adjust empty font names on some platforms. - func settableFontName(for fontName: String) -> String { - #if macOS - fontName - #else - fontName - #endif - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Indent.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Indent.swift deleted file mode 100644 index 0542b014a..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Indent.swift +++ /dev/null @@ -1,108 +0,0 @@ -// -// RichTextAttributeWriter+Indent.swift -// RichTextKit -// -// Created by James Bradley on 2022-03-04. -// Copyright © 2023 James Bradley. All rights reserved. -// - -import Foundation - -#if canImport(UIKit) -import UIKit -#endif - -#if canImport(AppKit) && !targetEnvironment(macCatalyst) -import AppKit -#endif - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeWriter { - - /// Set the rich text indent at a certain range. - /// - /// Unlike some other attributes, this attribute applies - /// to the entire paragraph, not just the selected range. - func stepRichTextIndent( - points: CGFloat, - at range: NSRange - ) -> RichTextAttributes? { - let text = richText.string - - // Text view has selected text - if range.length > 0 { - return stepIndentInternal(points: points, at: range) - } - - // The cursor is at the beginning of the text - if range.location == 0 { - return stepRichTextIndent(points: points, atIndex: 0) - } - - // The cursor is immediately before a newline - if let char = text.character(at: range.location), char.isNewLineSeparator { - let location = UInt(range.location) - let index = text.findIndexOfCurrentParagraph(from: location) - return stepRichTextIndent(points: points, atIndex: index) - } - - // The cursor is somewhere within a paragraph - let location = UInt(range.location) - let index = text.findIndexOfCurrentParagraph(from: location) - return stepRichTextIndent(points: points, atIndex: index) - } -} - -private extension RichTextAttributeWriter { - - /// Step the rich text indent at a certain index. - func stepRichTextIndent( - points: CGFloat, - atIndex index: Int - ) -> RichTextAttributes? { - guard let text = mutableRichText else { return nil } - let range = NSRange(location: index, length: 1) - let safeRange = safeRange(for: range, isAttributeOperation: true) - var attributes = text.attributes(at: safeRange.location, effectiveRange: nil) - let style = attributes[.paragraphStyle] as? NSMutableParagraphStyle ?? NSMutableParagraphStyle() - - let newIndent = max(style.headIndent + points, 0) - style.firstLineHeadIndent = newIndent - style.headIndent = newIndent - - attributes[.paragraphStyle] = style - text.beginEditing() - text.setAttributes(attributes, range: safeRange) - text.fixAttributes(in: safeRange) - text.endEditing() - - return attributes - } - - /// Step the rich text indent at a certain index. - func stepRichTextIndent( - points: CGFloat, - atIndex index: UInt - ) -> RichTextAttributes? { - stepRichTextIndent( - points: points, - atIndex: Int(index) - ) - } - - /// Step the text indent at a certain range. - func stepIndentInternal( - points: CGFloat, - at range: NSRange - ) -> RichTextAttributes? { - let text = richText.string - _ = range.length - let location = range.location - let ulocation = UInt(location) - let index = text.findIndexOfCurrentParagraph(from: ulocation) - return stepRichTextIndent( - points: points, - atIndex: index - ) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Paragraph.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Paragraph.swift deleted file mode 100644 index 77b29d735..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Paragraph.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// RichTextAttributeWriter+Paragraph.swift -// RichTextKit -// -// Created by Daniel Saidi on 2024-02-14. -// Copyright © 2023-2024 Daniel Saidi. All rights reserved. -// - -import Foundation - -#if canImport(UIKit) -import UIKit -#endif - -#if canImport(AppKit) && !targetEnvironment(macCatalyst) -import AppKit -#endif - -@available(*, deprecated, message: "Use RichTextViewComponent instead.") -public extension RichTextAttributeWriter { - - /// Set the rich text paragraph style at a certain range. - func setRichTextParagraphStyle( - to style: NSParagraphStyle, - at range: NSRange - ) { - let text = richText.string - let length = range.length - let location = range.location - let ulocation = UInt(location) - let uindex = text.findIndexOfCurrentParagraph(from: ulocation) - let index = Int(uindex) - let diff = location - index - let newLength = max(length + diff, 1) - let newRange = NSRange(location: index, length: newLength) - let safeRange = safeRange(for: newRange) - setRichTextAttribute(.paragraphStyle, to: style, at: safeRange) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Styles.swift b/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Styles.swift deleted file mode 100644 index e2f19df53..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextAttributeWriter+Styles.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// RichTextAttributeWriter+Styles.swift -// RichTextKit -// -// Created by Daniel Saidi on 2022-05-28. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use RichTextViewComponent instead") -public extension RichTextAttributeWriter { - - /// Set a rich text style at a certain range. - func setRichTextStyle( - _ style: RichTextStyle, - to newValue: Bool, - at range: NSRange - ) { - let value = newValue ? 1 : 0 - let range = safeRange(for: range) - switch style { - case .bold, .italic: - let styles = richTextStyles(at: range) - guard styles.shouldAddOrRemove(style, newValue) else { return } - guard let font = richTextFont(at: range) else { return } - guard let newFont = font.toggling(style) else { return } - setRichTextFont(newFont, at: range) - case .strikethrough: - setRichTextAttribute(.strikethroughStyle, to: value, at: range) - case .underlined: - setRichTextAttribute(.underlineStyle, to: value, at: range) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift deleted file mode 100644 index 034d3a58a..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextColorPicker+Deprecated.swift +++ /dev/null @@ -1,119 +0,0 @@ -#if iOS || macOS -import SwiftUI - -@available(*, deprecated, renamed: "RichTextColor.Picker") -public typealias RichTextColorPicker = RichTextColor.Picker - -public extension RichTextColor.Picker { - - @available(*, deprecated, renamed: "init(icon:value:showIcon:quickColors:)") - init( - color: PickerColor, - value: Binding, - showIcon: Bool = true, - quickColors: [Color] = [] - ) { - self.init( - type: .foreground, - icon: showIcon ? color.icon : nil, - value: value, - quickColors: quickColors - ) - } - - @available(*, deprecated, renamed: "init(icon:value:showIcon:quickColors:)") - init( - color: PickerColor, - value: Binding, - showIcon: Bool = true, - quickPickerColors: [RichTextColorPickerColor] - ) { - self.init( - color: color, - value: value, - showIcon: showIcon, - quickColors: quickPickerColors.colors - ) - } - - @available(*, deprecated, renamed: "init(icon:value:showIcon:quickColors:)") - init( - color: PickerColor, - context: RichTextContext, - showIcon: Bool = true, - quickColors: [Color] = [] - ) { - self.init( - color: color, - value: { - switch color { - case .foreground: return context.binding(for: .foreground) - case .background: return context.binding(for: .background) - } - }(), - showIcon: showIcon, - quickColors: quickColors - ) - } - - @available(*, deprecated, renamed: "init(icon:value:showIcon:quickColors:)") - init( - color: PickerColor, - context: RichTextContext, - showIcon: Bool = true, - quickPickerColors: [RichTextColorPickerColor] - ) { - self.init( - color: color, - value: { - switch color { - case .foreground: return context.binding(for: .foreground) - case .background: return context.binding(for: .background) - } - }(), - showIcon: showIcon, - quickColors: quickPickerColors.colors - ) - } -} - -public extension RichTextColor.Picker { - - @available(*, deprecated, message: "PickerColor is no longer used.") - enum PickerColor: String, CaseIterable, Identifiable { - case foreground, background - - var icon: Image { - switch self { - case .foreground: return Image.richTextColorForeground - case .background: return Image.richTextColorBackground - } - } - } -} - -@available(*, deprecated, message: "PickerColor is no longer used.") -public extension RichTextColorPicker.PickerColor { - - /// All available picker colors. - static var all: [Self] { allCases } - - /// The color's unique identifier. - var id: String { rawValue } - - /// The color's localized name. - var localizedName: String { - switch self { - case .foreground: return RTKL10n.foregroundColor.text - case .background: return RTKL10n.backgroundColor.text - } - } -} - -@available(*, deprecated, message: "PickerColor is no longer used.") -public extension Collection where Element == RichTextColorPicker.PickerColor { - - /// All available picker colors. - static var all: [RichTextColorPicker.PickerColor] { RichTextColorPicker.PickerColor.allCases } -} -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextColorPickerColor+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextColorPickerColor+Deprecated.swift deleted file mode 100644 index c328e792f..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextColorPickerColor+Deprecated.swift +++ /dev/null @@ -1,91 +0,0 @@ -import SwiftUI - -@available(*, deprecated, message: "RichTextColorPickerColor is no longer used.") -public enum RichTextColorPickerColor: String, CaseIterable, Codable, Equatable, Identifiable { - - case black - case gray - case white - - case blue - case brown - case cyan - case green - case indigo - case mint - case orange - case pink - case purple - case red - case teal - case yellow -} - -@available(*, deprecated, message: "RichTextColorPickerColor is no longer used.") -public extension RichTextColorPickerColor { - - /// The unique ID of the color. - var id: String { rawValue } - - /// The name of the color. - var name: String { rawValue } - - /// The SwiftUI color that the color represents, if any. - /// - /// This returns `nil` if the operating system has a too - /// low version number. - var color: Color? { - switch self { - case .black: return .black - case .gray: return .gray - case .white: return .white - - case .blue: return .blue - case .brown: return .brown - case .cyan: return .cyan - case .green: return .green - case .indigo: return .indigo - case .mint: return .mint - case .orange: return .orange - case .pink: return .pink - case .purple: return .purple - case .red: return .red - case .teal: return .teal - case .yellow: return .yellow - } - } - - /// Whether or not the color is available for the system. - var isAvailable: Bool { - color != nil - } - - /// Get a curated list of picker colors. - static var curated: [Self] { - [ - .black, .gray, .white, - .red, .pink, .orange, .yellow, - .indigo, .purple, .blue, .cyan, .teal, .mint, - .green, .brown - ] - } - - /// Get a random picker color. - static var random: Self? { - allCases.randomElement() - } -} - -@available(*, deprecated, message: "RichTextColorPickerColor is no longer used.") -public extension Collection where Element == RichTextColorPickerColor { - - /// Get all available SwiftUI colors from the collection. - var colors: [Color] { - compactMap { $0.color } - } - - /// Get a curated list of picker colors. - static var curated: [RichTextColorPickerColor] { - RichTextColorPickerColor.curated - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommand+AlignmentOptionsGroup.swift b/Sources/RichTextKit/_Deprecated/RichTextCommand+AlignmentOptionsGroup.swift deleted file mode 100644 index d629df989..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommand+AlignmentOptionsGroup.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// 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 { - - @available(*, deprecated, message: "Use RichTextCommand.ActionButtonGroup alignments initializer instead.") - struct AlignmentOptionsGroup: View { - - public init() {} - - public var body: some View { - ActionButtonGroup( - actions: RichTextAlignment.allCases.map { - .setAlignment($0) - } - ) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommand+FontSizeOptionsGroup.swift b/Sources/RichTextKit/_Deprecated/RichTextCommand+FontSizeOptionsGroup.swift deleted file mode 100644 index 966fb65e1..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommand+FontSizeOptionsGroup.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// 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 { - - @available(*, deprecated, message: "Use RichTextCommand.ActionButtonGroup fontSize initializer instead.") - struct FontSizeOptionsGroup: View { - - public init() {} - - public var body: some View { - ActionButtonGroup( - actions: [ - .increaseFontSize(), - .decreaseFontSize() - ] - ) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommand+IndentOptionsGroup.swift b/Sources/RichTextKit/_Deprecated/RichTextCommand+IndentOptionsGroup.swift deleted file mode 100644 index 88f750919..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommand+IndentOptionsGroup.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// 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 { - - @available(*, deprecated, message: "Use RichTextCommand.ActionButtonGroup indent initializer instead.") - struct IndentOptionsGroup: View { - - public var body: some View { - ActionButtonGroup( - actions: [ - .increaseIndent(), - .decreaseIndent() - ] - ) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommand+StyleOptionsGroup.swift b/Sources/RichTextKit/_Deprecated/RichTextCommand+StyleOptionsGroup.swift deleted file mode 100644 index d46e7fa88..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommand+StyleOptionsGroup.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// 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 { - - @available(*, deprecated, message: "Use RichTextCommand.ActionButtonGroup styles initializer instead.") - struct StyleOptionsGroup: View { - - public init() {} - - public var body: some View { - ActionButtonGroup( - actions: RichTextStyle.allCases.map { - .toggleStyle($0) - } - ) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommand+SuperscriptOptionsGroup.swift b/Sources/RichTextKit/_Deprecated/RichTextCommand+SuperscriptOptionsGroup.swift deleted file mode 100644 index 75f5c0713..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommand+SuperscriptOptionsGroup.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// RichTextCommand+SuperscriptOptionsGroup.swift -// RichTextKit -// -// Created by Daniel Saidi on 2024-02-14. -// Copyright © 2024 Daniel Saidi. All rights reserved. -// - -import SwiftUI - -public extension RichTextCommand { - - @available(*, deprecated, message: "Use RichTextCommand.ActionButtonGroup superscript initializer instead.") - struct SuperscriptOptionsGroup: View { - - public var body: some View { - ActionButtonGroup( - actions: [ - .increaseSuperscript(), - .decreaseSuperscript() - ] - ) - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift deleted file mode 100644 index 916dfc418..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCommands+Deprecated.swift +++ /dev/null @@ -1,27 +0,0 @@ -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 - -#if iOS || macOS || os(visionOS) -@available(*, deprecated, renamed: "RichTextCommand.FormatMenu") -public typealias RichTextFormatCommandMenu = RichTextCommand.FormatMenu - -@available(*, deprecated, renamed: "RichTextCommand.ShareMenu") -public typealias RichTextShareCommandMenu = RichTextCommand.ShareMenu -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextContext+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextContext+Deprecated.swift deleted file mode 100644 index 1dcf37a9a..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextContext+Deprecated.swift +++ /dev/null @@ -1,102 +0,0 @@ -import SwiftUI -import Combine - -public extension RichTextContext { - - @available(*, deprecated, renamed: "actionPublisher") - var userActionPublisher: PassthroughSubject { actionPublisher } - - @available(*, deprecated, message: "Use handle(_:) instead") - func decrementFontSize(points: UInt = 1) { - handle(.decreaseFontSize(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) instead") - func incrementFontSize(points: UInt = 1) { - handle(.increaseFontSize(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) instead") - func increaseFontSize(points: UInt = 1) { - handle(.increaseFontSize(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) instead") - func decreaseFontSize(points: UInt = 1) { - handle(.decreaseFontSize(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) instead") - func increaseIndent(points: UInt = 1) { - handle(.increaseIndent(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) instead") - func decreaseIndent(points: UInt = 1) { - handle(.decreaseIndent(points: points)) - } - - @available(*, deprecated, message: "Use handle(_:) with the .pasteImage action") - func pasteImage( - _ image: ImageRepresentable, - at index: Int? = nil, - moveCursorToPastedContent: Bool = false - ) { - let index = index ?? selectedRange.location - actionPublisher.send( - .pasteImage( - RichTextInsertion( - content: image, - at: index, - moveCursor: moveCursorToPastedContent - ) - ) - ) - } - - @available(*, deprecated, message: "Use handle(_:) with the .pasteImages action") - func pasteImages( - _ images: [ImageRepresentable], - at index: Int? = nil, - moveCursorToPastedContent: Bool = false - ) { - let index = index ?? selectedRange.location - actionPublisher.send( - .pasteImages( - RichTextInsertion( - content: images, - at: index, - moveCursor: moveCursorToPastedContent - ) - ) - ) - } - - @available(*, deprecated, message: "Use handle(_:) with the .pasteText action") - func pasteText( - _ text: String, - at index: Int? = nil, - moveCursorToPastedContent: Bool = false - ) { - let index = index ?? selectedRange.location - actionPublisher.send( - .pasteText( - RichTextInsertion( - content: text, - at: index, - moveCursor: moveCursorToPastedContent - ) - ) - ) - } - - @available(*, deprecated, renamed: "setStyle") - func set(_ style: RichTextStyle, to val: Bool) { - setStyle(style, to: val) - } - - @available(*, deprecated, renamed: "toggleStyle") - func toggle(_ style: RichTextStyle) { - toggleStyle(style) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextCoordinator+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextCoordinator+Deprecated.swift deleted file mode 100644 index 3e071473f..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextCoordinator+Deprecated.swift +++ /dev/null @@ -1,11 +0,0 @@ -#if iOS || macOS || os(tvOS) || os(visionOS) -import SwiftUI - -public extension RichTextCoordinator { - - @available(*, deprecated, renamed: "context") - var richTextContext: RichTextContext { - context - } -} -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextData+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextData+Deprecated.swift deleted file mode 100644 index 8bd8e7aa4..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextData+Deprecated.swift +++ /dev/null @@ -1,6 +0,0 @@ -import SwiftUI - -#if iOS || os(visionOS) -@available(*, deprecated, renamed: "RichTextDataFormat.Menu") -public typealias RichTextDataFormatMenu = RichTextDataFormat.Menu -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextFont+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextFont+Deprecated.swift deleted file mode 100644 index 1caf9c278..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextFont+Deprecated.swift +++ /dev/null @@ -1,37 +0,0 @@ -import SwiftUI - -@available(*, deprecated, renamed: "RichTextFont.Picker") -public typealias RichTextFontPicker = RichTextFont.Picker - -@available(*, deprecated, renamed: "RichTextFont.ForEachPicker") -public typealias RichTextFontForEachPicker = RichTextFont.ForEachPicker - -@available(*, deprecated, renamed: "RichTextFont.ListPicker") -public typealias RichTextFontListPicker = RichTextFont.ListPicker - -@available(*, deprecated, renamed: "RichTextFont.PickerFont") -public typealias RichTextFontPickerFont = RichTextFont.PickerFont - -@available(*, deprecated, renamed: "RichTextFont.SizePicker") -public typealias RichTextFontSizePicker = RichTextFont.SizePicker - -#if iOS || macOS || os(visionOS) -@available(*, deprecated, renamed: "RichTextFont.SizePickerStack") -public typealias RichTextFontSizePickerStack = RichTextFont.SizePickerStack -#endif - -public extension RichTextFont.SizePicker { - - @available(*, deprecated, renamed: "standardValues") - static var standardFontSizes: [CGFloat] { - standardValues - } - - @available(*, deprecated, renamed: "values(for:selection:)") - static func fontSizePickerSizes( - for sizes: [CGFloat], - selection: CGFloat - ) -> [CGFloat] { - values(for: sizes, selection: selection) - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextFormatSheet+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextFormatSheet+Deprecated.swift deleted file mode 100644 index bb8c25165..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextFormatSheet+Deprecated.swift +++ /dev/null @@ -1,31 +0,0 @@ -#if iOS || macOS || os(visionOS) -import SwiftUI - -public extension RichTextFormatSheet { - - @available(*, deprecated, message: "Use the config initializer instead.") - init( - context: RichTextContext, - colorPickers: [RichTextColor] - ) { - self.init( - context: context, - config: .init(colorPickers: colorPickers) - ) - } -} - -public extension RichTextFormatSidebar { - - @available(*, deprecated, message: "Use the config initializer instead.") - init( - context: RichTextContext, - colorPickers: [RichTextColor] = [.foreground, .background] - ) { - self.init( - context: context, - config: .init(colorPickers: colorPickers) - ) - } -} -#endif diff --git a/Sources/RichTextKit/_Deprecated/RichTextIndent+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextIndent+Deprecated.swift deleted file mode 100644 index 0f8a05691..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextIndent+Deprecated.swift +++ /dev/null @@ -1,26 +0,0 @@ -import SwiftUI - -@available(*, deprecated, message: "This type is no longer used") -public enum RichTextIndent: CaseIterable, Codable, Equatable, Identifiable { - - /// Reduce indent space. - case decrease - - /// Increase indent space. - case increase -} - -@available(*, deprecated, message: "This type is no longer used") -public extension RichTextIndent { - - /// The indent's unique ID. - var id: UUID { UUID() } - - /// The indent's standard icon. - var icon: Image { - switch self { - case .decrease: return .richTextIndentDecrease - case .increase: return .richTextIndentIncrease - } - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextIndentPicker.swift b/Sources/RichTextKit/_Deprecated/RichTextIndentPicker.swift deleted file mode 100644 index 8dfb0d342..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextIndentPicker.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// RichTextIndentPicker.swift -// RichTextKit -// -// Created by James Bradley on 2022-03-04. -// Copyright © 2023 James Bradley. All rights reserved. -// - -import SwiftUI - -@available(*, deprecated, message: "This is no longer used. Use a RichTextActionButtonGroup instead.") -public struct RichTextIndentPicker: View { - - public init( - selection: Binding, - values: [RichTextIndent] = RichTextIndent.allCases - ) { - self._selection = selection - self.values = values - } - - let values: [RichTextIndent] - - @Binding - private var selection: RichTextIndent - - public var body: some View { - Picker("", selection: $selection) { - ForEach(RichTextIndent.allCases) { - $0.icon.tag($0) - } - }.labelsHidden() - } -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextStyle+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextStyle+Deprecated.swift deleted file mode 100644 index 6f3a994a7..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextStyle+Deprecated.swift +++ /dev/null @@ -1,163 +0,0 @@ -import SwiftUI - -@available(*, deprecated, renamed: "RichTextStyle.Button") -public typealias RichTextStyleButton = RichTextStyle.Button - -@available(*, deprecated, renamed: "RichTextStyle.Toggle") -public typealias RichTextStyleToggle = RichTextStyle.Toggle - -#if iOS || macOS || os(visionOS) -@available(*, deprecated, renamed: "RichTextStyle.ToggleGroup") -public typealias RichTextStyleToggleGroup = RichTextStyle.ToggleGroup -#endif - -@available(*, deprecated, renamed: "RichTextStyle.ToggleStack") -public typealias RichTextStyleToggleStack = RichTextStyle.ToggleStack - -public extension RichTextStyle.Button { - - @available(*, deprecated, message: "Use foregroundStyle and accentColor instead of style.") - init( - style: RichTextStyle, - buttonStyle: Style = .standard, - value: Binding, - fillVertically: Bool = false - ) { - self.init( - style: style, - value: value, - fillVertically: fillVertically - ) - } - - @available(*, deprecated, message: "Use foregroundStyle and accentColor instead of style.") - init( - style: RichTextStyle, - buttonStyle: Style = .standard, - context: RichTextContext, - fillVertically: Bool = false - ) { - self.init( - style: style, - context: context, - fillVertically: fillVertically - ) - } -} - -public extension RichTextStyle.Toggle { - - @available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") - init( - style: RichTextStyle, - buttonStyle: Style = .standard, - value: Binding, - fillVertically: Bool = false - ) { - self.init( - style: style, - value: value, - fillVertically: fillVertically - ) - } - - @available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") - init( - style: RichTextStyle, - buttonStyle: Style = .standard, - context: RichTextContext, - fillVertically: Bool = false - ) { - self.init( - style: style, - context: context, - fillVertically: fillVertically - ) - } -} - -#if iOS || macOS || os(visionOS) -public extension RichTextStyle.ToggleGroup { - - @available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") - init( - context: RichTextContext, - styles: [RichTextStyle] = .all, - greedy: Bool = true, - buttonStyle: RichTextStyle.Toggle.Style = .standard - ) { - self.init( - context: context, - styles: styles, - greedy: greedy - ) - } -} -#endif - -public extension RichTextStyle.ToggleStack { - - @available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") - init( - context: RichTextContext, - styles: [RichTextStyle] = .all, - buttonStyle: RichTextStyle.Toggle.Style = .standard, - spacing: Double = 5 - ) { - self.init( - context: context, - styles: styles, - spacing: spacing - ) - } -} - -public extension RichTextStyle.Button { - - @available(*, deprecated, message: "Use foregroundStyle and accentColor instead of style.") - struct Style { - - public init( - inactiveColor: Color = .primary, - activeColor: Color = .blue - ) { - self.inactiveColor = inactiveColor - self.activeColor = activeColor - } - - public var inactiveColor: Color - - public var activeColor: Color - } -} - -public extension RichTextStyle.Toggle { - - @available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") - struct Style { - - public init( - inactiveColor: Color? = nil, - activeColor: Color = .blue - ) { - self.inactiveColor = inactiveColor - self.activeColor = activeColor - } - - public var inactiveColor: Color? - - public var activeColor: Color - } -} - -@available(*, deprecated, message: "Use foregroundStyle and accentColor instead of style.") -public extension RichTextStyle.Button.Style { - - static var standard = RichTextStyle.Button.Style() -} - -@available(*, deprecated, message: "Use foregroundStyle and tint instead of style.") -public extension RichTextStyle.Toggle.Style { - - static var standard = RichTextStyle.Toggle.Style() -} diff --git a/Sources/RichTextKit/_Deprecated/RichTextViewComponent+Deprecated.swift b/Sources/RichTextKit/_Deprecated/RichTextViewComponent+Deprecated.swift deleted file mode 100644 index 2f6f25ee1..000000000 --- a/Sources/RichTextKit/_Deprecated/RichTextViewComponent+Deprecated.swift +++ /dev/null @@ -1,218 +0,0 @@ -import Foundation - -public extension RichTextViewComponent { - - @available(*, deprecated, message: "Use richTextFont?.fontName instead") - var richTextFontName: String? { - richTextFont?.fontName - } - - @available(*, deprecated, message: "Use richTextFont?.pointSize instead") - var richTextFontSize: CGFloat? { - richTextFont?.pointSize - } - - @available(*, deprecated, renamed: "currentColor(_:)") - var currentBackgroundColor: ColorRepresentable? { - currentColor(.background) - } - - @available(*, deprecated, renamed: "currentColor(_:)") - var currentForegroundColor: ColorRepresentable? { - currentColor(.foreground) - } - - @available(*, deprecated, renamed: "currentColor(_:)") - var currentStrokeColor: ColorRepresentable? { - currentColor(.stroke) - } - - @available(*, deprecated, renamed: "currentColor(_:)") - var currentStrikethroughColor: ColorRepresentable? { - currentColor(.strikethrough) - } - - @available(*, deprecated, renamed: "setCurrentColor(_:to:)") - func setCurrentBackgroundColor( - _ color: ColorRepresentable - ) { - setCurrentColor(.background, to: color) - } - - @available(*, deprecated, renamed: "setCurrentColor(_:to:)") - func setCurrentForegroundColor( - _ color: ColorRepresentable - ) { - setCurrentColor(.foreground, to: color) - } - - @available(*, deprecated, renamed: "setCurrentColor(_:to:)") - func setCurrentStrokeColor( - _ color: ColorRepresentable - ) { - setCurrentColor(.stroke, to: color) - } - - @available(*, deprecated, renamed: "setCurrentColor(_:to:)") - func setCurrentStrikethroughColor( - _ color: ColorRepresentable - ) { - setCurrentColor(.strikethrough, to: color) - } - - @available(*, deprecated, renamed: "currentTextAlignment") - var currentRichTextAlignment: RichTextAlignment? { - currentTextAlignment - } - - @available(*, deprecated, renamed: "setCurrentTextAlignment(_:)") - func setCurrentRichTextAlignment( - to alignment: RichTextAlignment - ) { - setCurrentTextAlignment(alignment) - } - - @available(*, deprecated, renamed: "setCurrentBackgroundColor(_:)") - func setCurrentBackgroundColor( - to color: ColorRepresentable - ) { - setCurrentBackgroundColor(color) - } - - @available(*, deprecated, renamed: "setCurrentForegroundColor(_:)") - func setCurrentForegroundColor( - to color: ColorRepresentable - ) { - setCurrentForegroundColor(color) - } - - @available(*, deprecated, renamed: "setCurrentFont(_:)") - func setCurrentFont(to font: FontRepresentable) { - setCurrentFont(font) - } - - @available(*, deprecated, renamed: "setCurrentFontName(_:)") - func setCurrentFontName(to name: String) { - setCurrentFontName(name) - } - - @available(*, deprecated, renamed: "setCurrentFontSize(_:)") - func setCurrentFontSize(to size: CGFloat) { - setCurrentFontSize(size) - } - - @available(*, deprecated, message: "Use stepCurrentFontSize instead.") - func decrementCurrentFontSize(points: UInt = 1) { - stepCurrentFontSize(points: -Int(points)) - } - - @available(*, deprecated, message: "Use stepCurrentFontSize instead.") - func incrementCurrentFontSize(points: UInt = 1) { - stepCurrentFontSize(points: Int(points)) - } -} - -public extension RichTextViewComponent { - - @available(*, deprecated, message: "richTextAttributes") - var currentRichTextAttributes: RichTextAttributes { - richTextAttributes - } - - @available(*, deprecated, message: "richTextAttribute(_:)") - func currentRichTextAttribute(_ attribute: RichTextAttribute) -> Value? { - richTextAttributes[attribute] as? Value - } - - @available(*, deprecated, message: "setRichTextAttribute(_:to:)") - func setCurrentRichTextAttribute(_ attribute: RichTextAttribute, to value: Any) { - setRichTextAttribute(attribute, to: value) - } - - @available(*, deprecated, message: "setRichTextAttributes(_:)") - func setCurrentRichTextAttributes(_ attributes: RichTextAttributes) { - setRichTextAttributes(attributes) - } - - @available(*, deprecated, message: "richTextAlignment") - var currentTextAlignment: RichTextAlignment? { - richTextAlignment - } - - @available(*, deprecated, message: "setRichTextAlignment(_:)") - func setCurrentTextAlignment(_ alignment: RichTextAlignment) { - setRichTextAlignment(alignment) - } - - @available(*, deprecated, message: "richTextColor(_:)") - func currentColor(_ color: RichTextColor) -> ColorRepresentable? { - richTextColor(color) - } - - @available(*, deprecated, message: "setRichTextColor(_:to:)") - func setCurrentColor(_ color: RichTextColor, to val: ColorRepresentable) { - if currentColor(color) == val { return } - guard let attribute = color.attribute else { return } - setRichTextAttribute(attribute, to: val) - } - - @available(*, deprecated, message: "richTextFont") - var currentFont: FontRepresentable? { - richTextFont - } - - @available(*, deprecated, message: "Use richTextFont?.pointSize instead") - var currentFontSize: CGFloat? { - richTextFontSize - } - - @available(*, deprecated, message: "Use richTextFont?.fontName instead") - var currentFontName: String? { - richTextFontName - } - - @available(*, deprecated, message: "setRichTextFont(_:)") - func setCurrentFont(_ font: FontRepresentable) { - setRichTextFont(font) - } - - @available(*, deprecated, message: "setRichTextFontName(_:)") - func setCurrentFontName(_ name: String) { - setRichTextFontName(name) - } - - @available(*, deprecated, message: "setRichTextFontSize(_:)") - func setCurrentFontSize(_ size: CGFloat) { - setRichTextFontSize(size) - } - - @available(*, deprecated, message: "stepRichTextFontSize(points:)") - func stepCurrentFontSize(points: Int) { - stepRichTextFontSize(points: points) - } - - @available(*, deprecated, message: "richTextIndent") - var currentIndent: CGFloat? { - richTextIndent - } - - @available(*, deprecated, message: "stepRichTextIndent(points:)") - func stepCurrentIndent( - points: CGFloat - ) { - stepRichTextIndent(points: points) - } - - @available(*, deprecated, message: "richTextStyles") - var currentRichTextStyles: [RichTextStyle] { - richTextStyles - } - - @available(*, deprecated, message: "setRichTextStyle(_:to:)") - func setCurrentRichTextStyle( - _ style: RichTextStyle, - to newValue: Bool - ) { - setRichTextStyle(style, to: newValue) - } -}