diff --git a/Sources/RichTextKit/Coordinator/RichTextCoordinator+Actions.swift b/Sources/RichTextKit/Coordinator/RichTextCoordinator+Actions.swift index 248d72153..fb13970b9 100644 --- a/Sources/RichTextKit/Coordinator/RichTextCoordinator+Actions.swift +++ b/Sources/RichTextKit/Coordinator/RichTextCoordinator+Actions.swift @@ -112,17 +112,17 @@ extension RichTextCoordinator { func setIsEditing(to newValue: Bool) { if newValue == textView.isFirstResponder { return } if newValue { -#if iOS || os(visionOS) + #if iOS || os(visionOS) textView.becomeFirstResponder() -#else + #else print("macOS currently doesn't resign first responder.") -#endif + #endif } else { -#if iOS || os(visionOS) + #if iOS || os(visionOS) textView.resignFirstResponder() -#else + #else print("macOS currently doesn't resign first responder.") -#endif + #endif } } diff --git a/Sources/RichTextKit/Coordinator/RichTextCoordinator+ColorSubscriptions.swift b/Sources/RichTextKit/Coordinator/RichTextCoordinator+ColorSubscriptions.swift index ec2f86831..03a692458 100644 --- a/Sources/RichTextKit/Coordinator/RichTextCoordinator+ColorSubscriptions.swift +++ b/Sources/RichTextKit/Coordinator/RichTextCoordinator+ColorSubscriptions.swift @@ -17,9 +17,9 @@ extension RichTextCoordinator { } guard let attribute = color.attribute else { return } if let applyRange { - self.textView.setRichTextColor(color, to: val, at: applyRange) + textView.setRichTextColor(color, to: val, at: applyRange) } else { - self.textView.setRichTextAttribute(attribute, to: val) + textView.setRichTextAttribute(attribute, to: val) } } } diff --git a/Sources/RichTextKit/Coordinator/RichTextCoordinator.swift b/Sources/RichTextKit/Coordinator/RichTextCoordinator.swift index ff543c29b..2318a2662 100644 --- a/Sources/RichTextKit/Coordinator/RichTextCoordinator.swift +++ b/Sources/RichTextKit/Coordinator/RichTextCoordinator.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-05-22. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // #if iOS || macOS || os(tvOS) || os(visionOS) @@ -13,14 +13,13 @@ import SwiftUI /** This coordinator is used to keep a ``RichTextView`` in sync with a ``RichTextContext``. + + This is used by ``RichTextEditor`` to coordinate changes in + its context and the underlying text view. - The coordinator sets itself as the text view's delegate and - updates the context when things change in the text view. It - also subscribes to context observable changes and keeps the - text view in sync with these changes. - - You can inherit this class to customize the coordinator for - your own use cases. + The coordinator sets itself as the text view's delegate. It + updates the context when things change in the text view and + syncs to context changes to the text view. */ open class RichTextCoordinator: NSObject { @@ -171,11 +170,7 @@ extension RichTextCoordinator { } } - /** - Sync the rich text context with the text view after the - dispatch queue delay above. The delay will silence some - purple alert warnings about how state is updated. - */ + /// Sync the rich text context with the text view. func syncContextWithTextViewAfterDelay() { let styles = textView.richTextStyles diff --git a/Sources/RichTextKit/Data/NSAttributedString+Init.swift b/Sources/RichTextKit/Data/NSAttributedString+Init.swift index 2b1be14b9..9ff05296b 100644 --- a/Sources/RichTextKit/Data/NSAttributedString+Init.swift +++ b/Sources/RichTextKit/Data/NSAttributedString+Init.swift @@ -32,15 +32,7 @@ public extension NSAttributedString { private extension NSAttributedString { - /** - Try to parse ``RichTextDataFormat/archivedData`` data. - - The data must have been generated with `NSKeyedArchiver` - and will be unarchived with a `NSKeyedUnarchiver`. - - - Parameters: - - data: The data to initialize the string with. - */ + /// Try to parse ``RichTextDataFormat/archivedData``. convenience init(archivedData data: Data) throws { let unarchived = try NSKeyedUnarchiver.unarchivedObject( ofClass: NSAttributedString.self, @@ -51,12 +43,7 @@ private extension NSAttributedString { self.init(attributedString: string) } - /** - Try to parse ``RichTextDataFormat/plainText`` data. - - - Parameters: - - data: The data to initialize the string with. - */ + /// Try to parse ``RichTextDataFormat/plainText`` data. convenience init(plainTextData data: Data) throws { let decoded = String(data: data, encoding: .utf8) guard let string = decoded else { @@ -66,9 +53,7 @@ private extension NSAttributedString { self.init(attributedString: attributed) } - /** - Try to parse ``RichTextDataFormat/rtf`` data. - */ + /// Try to parse ``RichTextDataFormat/rtf`` data. convenience init(rtfData data: Data) throws { var attributes = Self.rtfDataAttributes as NSDictionary? try self.init( @@ -78,9 +63,7 @@ private extension NSAttributedString { ) } - /** - Try to parse ``RichTextDataFormat/rtfd`` data. - */ + /// Try to parse ``RichTextDataFormat/rtfd`` data. convenience init(rtfdData data: Data) throws { var attributes = Self.rtfdDataAttributes as NSDictionary? try self.init( @@ -91,9 +74,7 @@ private extension NSAttributedString { } #if macOS - /** - Try to parse ``RichTextDataFormat/word`` data. - */ + /// Try to parse ``RichTextDataFormat/word`` data. convenience init(wordData data: Data) throws { var attributes = Self.wordDataAttributes as NSDictionary? try self.init( diff --git a/Sources/RichTextKit/Export/NSAttributedString+Export.swift b/Sources/RichTextKit/Export/NSAttributedString+Export.swift index ad447e7c6..1b4ef166a 100644 --- a/Sources/RichTextKit/Export/NSAttributedString+Export.swift +++ b/Sources/RichTextKit/Export/NSAttributedString+Export.swift @@ -3,18 +3,14 @@ // RichTextKit // // Created by Daniel Saidi on 2022-04-05. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation extension NSAttributedString { - /** - Make all text in the attributed string black to account - for dark mode, otherwise this text will not be adaptive - when switching to dark mode. - */ + /// Make all text black to account for dark mode. func withBlackText() -> NSAttributedString { let mutable = NSMutableAttributedString(attributedString: self) let range = mutable.safeRange(for: NSRange(location: 0, length: mutable.length)) diff --git a/Sources/RichTextKit/Export/RichTextExportError.swift b/Sources/RichTextKit/Export/RichTextExportError.swift index 39533d123..3d8b741bf 100644 --- a/Sources/RichTextKit/Export/RichTextExportError.swift +++ b/Sources/RichTextKit/Export/RichTextExportError.swift @@ -3,14 +3,14 @@ // RichTextKit // // Created by Daniel Saidi on 2022-06-02. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation /** - This enum defines errors that can be thrown when a file - manager fails to perform export operations. + This enum defines errors that can be thrown when failing to + export rich text. */ public enum RichTextExportError: Error { diff --git a/Sources/RichTextKit/Export/RichTextExportMenu.swift b/Sources/RichTextKit/Export/RichTextExportMenu.swift index 265eedeba..01eb41363 100644 --- a/Sources/RichTextKit/Export/RichTextExportMenu.swift +++ b/Sources/RichTextKit/Export/RichTextExportMenu.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-12-19. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // #if iOS || macOS || os(visionOS) @@ -14,12 +14,7 @@ import SwiftUI a list of ``RichTextDataFormat`` values. This menu uses a ``RichTextDataFormat/Menu`` configured for - exporting. It has customizable actions, to make it possible - to use it in any custom way. - - You can use a custom ``RichTextDataFormat`` you can use its - `convertibleFormats` as `formats` init parameter, to get an - export menu for all other formats. + exporting, with customizable actions and data formats. */ public struct RichTextExportMenu: View { diff --git a/Sources/RichTextKit/Export/RichTextExportService.swift b/Sources/RichTextKit/Export/RichTextExportService.swift index 23b277137..3ec39bbb3 100644 --- a/Sources/RichTextKit/Export/RichTextExportService.swift +++ b/Sources/RichTextKit/Export/RichTextExportService.swift @@ -3,18 +3,14 @@ // RichTextKit // // Created by Daniel Saidi on 2022-06-02. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation /** This protocol can be implemented by any classes that can be - used to export rich text files. - - Exporting a file can be used to convert a rich text between - various formats. To share or print the text, consider using - a ``RichTextShareService`` instead. + used to export rich text to files. */ public protocol RichTextExportService: AnyObject { diff --git a/Sources/RichTextKit/Export/StandardRichTextExportUrlResolver.swift b/Sources/RichTextKit/Export/RichTextExportUrlResolver+FileManager.swift similarity index 97% rename from Sources/RichTextKit/Export/StandardRichTextExportUrlResolver.swift rename to Sources/RichTextKit/Export/RichTextExportUrlResolver+FileManager.swift index 18a9e77ec..1b320ef21 100644 --- a/Sources/RichTextKit/Export/StandardRichTextExportUrlResolver.swift +++ b/Sources/RichTextKit/Export/RichTextExportUrlResolver+FileManager.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-06-02. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/RichTextKit/Export/RichTextExportUrlResolver.swift b/Sources/RichTextKit/Export/RichTextExportUrlResolver.swift index 315848291..2080a3b21 100644 --- a/Sources/RichTextKit/Export/RichTextExportUrlResolver.swift +++ b/Sources/RichTextKit/Export/RichTextExportUrlResolver.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-06-02. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation diff --git a/Sources/RichTextKit/Export/StandardRichTextExportService.swift b/Sources/RichTextKit/Export/StandardRichTextExportService.swift index ec4409bf6..0dd4d74e4 100644 --- a/Sources/RichTextKit/Export/StandardRichTextExportService.swift +++ b/Sources/RichTextKit/Export/StandardRichTextExportService.swift @@ -3,7 +3,7 @@ // RichTextKit // // Created by Daniel Saidi on 2022-06-02. -// Copyright © 2022-2023 Daniel Saidi. All rights reserved. +// Copyright © 2022-2024 Daniel Saidi. All rights reserved. // import Foundation @@ -12,9 +12,9 @@ import Foundation This export service can be used to export rich text content to files with a certain format. - Exported files are by default written to the app's document - folder, since the intent should be to export rich text with - another data format. + Files are by default written to the app document folder. It + can be changed by providing another searchpath directory in + the initializer. */ public class StandardRichTextExportService: RichTextExportService {