-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from danielsaidi/feature/only_config_it_can_be
[FEATURE] Extend configuration
- Loading branch information
Showing
9 changed files
with
179 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,13 @@ | ||
// | ||
// RichTextView+Config.swift | ||
// RichTextKit | ||
// | ||
// Created by Daniel Saidi on 2024-01-16. | ||
// Copyright © 2024 Daniel Saidi. All rights reserved. | ||
// | ||
// Created by Dominik Bucher on 13.02.2024. | ||
// | ||
|
||
#if iOS || macOS || os(tvOS) || os(visionOS) | ||
import SwiftUI | ||
|
||
public extension RichTextView { | ||
|
||
/** | ||
This type can be used to configure a ``RichTextEditor``. | ||
*/ | ||
struct Configuration { | ||
|
||
/** | ||
Create a custom configuration. | ||
|
||
- Parameters: | ||
- isScrollingEnabled: Whether or not the editor should scroll, by default `true`. | ||
*/ | ||
public init( | ||
isScrollingEnabled: Bool = true | ||
) { | ||
self.isScrollingEnabled = isScrollingEnabled | ||
} | ||
|
||
/// Whether or not the editor should scroll. | ||
public var isScrollingEnabled: Bool | ||
} | ||
} | ||
import Foundation | ||
|
||
public extension RichTextView.Configuration { | ||
|
||
/// Get a standard rich text editor configuration. | ||
static var standard: Self { .init() } | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// RichTextView+Config_AppKit.swift | ||
// | ||
// | ||
// Created by Dominik Bucher on 13.02.2024. | ||
// | ||
|
||
#if macOS | ||
import Foundation | ||
|
||
public extension RichTextView { | ||
|
||
/** | ||
This type can be used to configure a ``RichTextEditor``. | ||
*/ | ||
struct Configuration { | ||
|
||
/// Create a custom configuration | ||
/// - Parameters: | ||
/// - isScrollingEnabled: Whether or not the editor should scroll, by default `true`. | ||
/// - isContinuousSpellCheckingEnabled: Whether the editor spell-checks in realtime. Defaults to `true`. | ||
public init( | ||
isScrollingEnabled: Bool = true, | ||
isContinuousSpellCheckingEnabled: Bool = true | ||
) { | ||
self.isScrollingEnabled = isScrollingEnabled | ||
self.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled | ||
} | ||
|
||
/// Whether or not the editor should scroll. | ||
public var isScrollingEnabled: Bool | ||
/// Whether the editor spell-checks in realtime. | ||
public var isContinuousSpellCheckingEnabled: Bool | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// RichTextView+Config_UIKit.swift | ||
// RichTextKit | ||
// | ||
// Created by Daniel Saidi on 2024-01-16. | ||
// Copyright © 2024 Daniel Saidi. All rights reserved. | ||
// | ||
|
||
#if iOS || os(tvOS) || os(visionOS) | ||
import SwiftUI | ||
|
||
public extension RichTextView { | ||
|
||
/** | ||
This type can be used to configure a ``RichTextEditor``. | ||
*/ | ||
struct Configuration { | ||
|
||
/** | ||
Create a custom configuration. | ||
|
||
- Parameters: | ||
- isScrollingEnabled: Whether or not the editor should scroll, by default `true`. | ||
- allowsEditingTextAttributes: If editor allows editing text attributes, by default `true`. | ||
- autocapitalizationType: Type of Auto capitalization, default is to `.sentences`. | ||
- spellCheckingType: Whether textView spell-Checks, default is `.no`. | ||
*/ | ||
public init( | ||
isScrollingEnabled: Bool = true, | ||
allowsEditingTextAttributes: Bool = true, | ||
autocapitalizationType: UITextAutocapitalizationType = .sentences, | ||
spellCheckingType: UITextSpellCheckingType = .no | ||
) { | ||
self.isScrollingEnabled = isScrollingEnabled | ||
self.allowsEditingTextAttributes = allowsEditingTextAttributes | ||
self.autocapitalizationType = autocapitalizationType | ||
self.spellCheckingType = spellCheckingType | ||
} | ||
|
||
/// Whether or not the editor should scroll. | ||
public var isScrollingEnabled: Bool | ||
/// Whether textView allows editting text attributes | ||
public var allowsEditingTextAttributes: Bool | ||
/// Kind of auto capitalization | ||
public var autocapitalizationType: UITextAutocapitalizationType | ||
/// If TextView spell-checks the text. | ||
public var spellCheckingType: UITextSpellCheckingType | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// RichTextView+Theme.swift | ||
// RichTextKit | ||
// | ||
// Created by Dominik Bucher on 13.02.2024. | ||
// | ||
|
||
#if iOS || macOS || os(tvOS) || os(visionOS) | ||
import SwiftUI | ||
|
||
public extension RichTextView { | ||
|
||
/** | ||
This type can be used to configure a ``RichTextEditor``'s current color properties. | ||
*/ | ||
struct Theme { | ||
|
||
/** | ||
Create a custom configuration. | ||
|
||
- Parameters: | ||
- font: default `.systemFont` of point size `16` (this differs on iOS and macOS). | ||
- fontColor: default `.textColor`. | ||
- backgroundColor: Color of whole textView default `.clear`. | ||
*/ | ||
public init( | ||
font: FontRepresentable = .systemFont(ofSize: 16), | ||
fontColor: ColorRepresentable = .textColor, | ||
backgroundColor: ColorRepresentable = .clear | ||
) { | ||
self.font = font | ||
self.fontColor = fontColor | ||
self.backgroundColor = backgroundColor | ||
} | ||
|
||
public let font: FontRepresentable | ||
public let fontColor: ColorRepresentable | ||
public let backgroundColor: ColorRepresentable | ||
} | ||
} | ||
|
||
public extension RichTextView.Theme { | ||
|
||
/// Get a standard rich text editor configuration. | ||
static var standard: Self { .init() } | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters