Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftFormat - enable consecutiveBlankLines #139

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
--swiftversion 5.8

# rules
--rules consecutiveBlankLines
--rules consecutiveSpaces
--rules trailingSpace
23 changes: 11 additions & 12 deletions Sources/RichTextKit/Actions/RichTextAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public enum RichTextAction: Identifiable, Equatable, RichTextLabelValue {

/// Copy the currently selected text, if any.
case copy

/// Dismiss any presented software keyboard.
case dismissKeyboard

/// Paste a single image.
case pasteImage(RichTextInsertion<ImageRepresentable>)

/// Paste multiple images.
case pasteImages(RichTextInsertion<[ImageRepresentable]>)

/// Paste plain text.
case pasteText(RichTextInsertion<String>)

Expand All @@ -37,25 +37,25 @@ public enum RichTextAction: Identifiable, Equatable, RichTextLabelValue {

/// Redo the latest undone change.
case redoLatestChange

/// Select a range.
case selectRange(NSRange)

/// Set the text alignment.
case setAlignment(_ alignment: RichTextAlignment)

/// Set the entire attributed string.
case setAttributedString(NSAttributedString)

// Change background color
case setColor(RichTextColor, ColorRepresentable)

// Highlighted renge
case setHighlightedRange(NSRange?)

// Change highlighting style
case setHighlightingStyle(RichTextHighlightingStyle)

/// Set a certain ``RichTextStyle``.
case setStyle(RichTextStyle, Bool)

Expand Down Expand Up @@ -149,7 +149,6 @@ public extension RichTextAction {
}
}


// MARK: - Aliases

public extension RichTextAction {
Expand Down
1 change: 0 additions & 1 deletion Sources/RichTextKit/Colors/ColorRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import AppKit
public typealias ColorRepresentable = NSColor
#endif


#if iOS || os(tvOS) || os(watchOS) || os(visionOS)
import UIKit

Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Colors/RichTextColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public extension RichTextColor {
case .undefined: .richTextColorUndefined
}
}

/// The localized color title key.
var titleKey: RTKL10n {
switch self {
Expand Down
3 changes: 0 additions & 3 deletions Sources/RichTextKit/Component/RichTextViewComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public protocol RichTextViewComponent: AnyObject,
/// The text view current typing attributes.
var typingAttributes: RichTextAttributes { get set }


// MARK: - Setup

/// Setup the view with a text and data format.
Expand All @@ -62,7 +61,6 @@ public protocol RichTextViewComponent: AnyObject,
format: RichTextDataFormat
)


// MARK: - Functions

/// Show an alert with a title, message and button text.
Expand All @@ -87,7 +85,6 @@ public protocol RichTextViewComponent: AnyObject,
func undoLatestChange()
}


// MARK: - Public Extension

public extension RichTextViewComponent {
Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Context/RichTextContext+Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public extension RichTextContext {
) {
guard self.color(for: color) != val else { return }
userActionPublisher.send(.setColor(color, val))

switch color {
case .foreground: foregroundColor = val
case .background: backgroundColor = val
Expand Down
19 changes: 9 additions & 10 deletions Sources/RichTextKit/Context/RichTextContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Combine
/**
This observable context can be used to affect and observe a
``RichTextEditor`` and its content.

Use ``handle(_:)`` to trigger a change, e.g. to change font,
text style, alignment, select a range, etc. You can observe
the various published properties to keep your UI updated as
Expand Down Expand Up @@ -45,33 +45,32 @@ public class RichTextContext: ObservableObject {
/// The currently selected range, if any.
public internal(set) var selectedRange = NSRange()


// MARK: - Public properies

/// Whether or not the text is currently being edited.
@Published
public var isEditingText = false

/// The current text alignment, if any.
@Published
public var textAlignment: RichTextAlignment = .left

/// The current font name.
@Published
public var fontName = ""

/// The current font size.
@Published
public var fontSize = CGFloat.standardRichTextFontSize

/// The currently highlighted range, if any.
public var highlightedRange: NSRange?

/// Use this Publisher to emit any attribute changes to textView.
public let userActionPublisher: PassthroughSubject<RichTextAction, Never> = .init()

// MARK: - Internal properties

/// The current background color, if any.
@Published
public internal(set) var backgroundColor: ColorRepresentable?
Expand All @@ -95,7 +94,7 @@ public class RichTextContext: ObservableObject {
/// Whether or not the indent level can be increased.
@Published
public internal(set) var canIncreaseIndent = true

/// The current foreground color, if any.
@Published
public internal(set) var foregroundColor: ColorRepresentable?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

extension RichTextCoordinator {

func setColor(_ color: RichTextColor, to val: ColorRepresentable) {
var applyRange: NSRange? = nil
if textView.hasSelectedRange {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension RichTextCoordinator {
self?.handle(action)
}
.store(in: &cancellables)

subscribeToAlignment()
subscribeToFontName()
subscribeToFontSize()
Expand Down Expand Up @@ -117,7 +117,7 @@ extension RichTextCoordinator {
moveCursorToPastedContent: data.moveCursor
)
}

func pasteImages(_ data: RichTextInsertion<[ImageRepresentable]>?) {
guard let data = data else { return }
textView.pasteImages(
Expand All @@ -126,7 +126,7 @@ extension RichTextCoordinator {
moveCursorToPastedContent: data.moveCursor
)
}

func pasteText(_ data: RichTextInsertion<String>?) {
guard let data = data else { return }
textView.pasteText(
Expand Down
7 changes: 0 additions & 7 deletions Sources/RichTextKit/Coordinator/RichTextCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ open class RichTextCoordinator: NSObject {
subscribeToUserActions()
}


// MARK: - Properties

/// The rich text context to coordinate with.
Expand All @@ -66,7 +65,6 @@ open class RichTextCoordinator: NSObject {
/// This flag is used to avoid delaying context sync.
var shouldDelaySyncContextWithTextView = true


// MARK: - Internal Properties

/**
Expand All @@ -81,7 +79,6 @@ open class RichTextCoordinator: NSObject {
*/
var highlightedRangeOriginalForegroundColor: ColorRepresentable?


#if canImport(UIKit)

// MARK: - UITextViewDelegate
Expand All @@ -103,7 +100,6 @@ open class RichTextCoordinator: NSObject {
}
#endif


#if canImport(AppKit) && !targetEnvironment(macCatalyst)

// MARK: - NSTextViewDelegate
Expand All @@ -126,7 +122,6 @@ open class RichTextCoordinator: NSObject {
#endif
}


#if iOS || os(tvOS) || os(visionOS)
import UIKit

Expand All @@ -138,7 +133,6 @@ import AppKit
extension RichTextCoordinator: NSTextViewDelegate {}
#endif


// MARK: - Public Extensions

public extension RichTextCoordinator {
Expand All @@ -155,7 +149,6 @@ public extension RichTextCoordinator {
}
}


// MARK: - Internal Extensions

extension RichTextCoordinator {
Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Data/RichTextDataFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import UniformTypeIdentifiers
can be used elsewhere.

``archivedData`` uses an `rtk` file extension, as well as a
`UTType.archivedData` uniform type. You can create a custom
`UTType.archivedData` uniform type. You can create a custom
``vendorArchivedData(id:fileExtension:fileFormatText:uniformType:)``
value to specify a custom data format.

Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Fonts/RichTextFont+Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public extension RichTextFont {

/**
This font picker can be used to pick a font from a list.

This picker uses ``RichTextFont/PickerFont/all`` as the
default fonts.

Expand Down
4 changes: 0 additions & 4 deletions Sources/RichTextKit/Fonts/RichTextFont+PickerFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public extension RichTextFont {
}
}


// MARK: - Static Properties

public extension RichTextFont.PickerFont {
Expand Down Expand Up @@ -92,7 +91,6 @@ public extension RichTextFont.PickerFont {
}
}


// MARK: - Public Properties

public extension RichTextFont.PickerFont {
Expand All @@ -113,7 +111,6 @@ public extension RichTextFont.PickerFont {
}
}


// MARK: - Collection Extensions

public extension Collection where Element == RichTextFont.PickerFont {
Expand All @@ -135,7 +132,6 @@ public extension Collection where Element == RichTextFont.PickerFont {
}
}


// MARK: - System Fonts

private extension RichTextFont.PickerFont {
Expand Down
1 change: 0 additions & 1 deletion Sources/RichTextKit/Format/RichTextFormatSidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public struct RichTextFormatSidebar: View {
}
}


private struct SidebarSection<Content: View>: View {

let title: String?
Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Images/Image+RichText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public extension Image {

static let richTextIndentDecrease = symbol("decrease.indent")
static let richTextIndentIncrease = symbol("increase.indent")

static let richTextSelection = symbol("123.rectangle.fill")

static let richTextStyleBold = symbol("bold")
Expand Down
2 changes: 0 additions & 2 deletions Sources/RichTextKit/Images/RichTextImageAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,13 @@ open class RichTextImageAttachment: NSTextAttachment {
super.init(coder: coder)
}


/**
Whether or not the attachment supports secure coding.

This attachment type supports secure coding by default.
*/
public override class var supportsSecureCoding: Bool { true }


#if iOS || os(tvOS) || os(visionOS)
/**
Get or set the attachment image.
Expand Down
10 changes: 5 additions & 5 deletions Sources/RichTextKit/Localization/RTKL10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum RTKL10n: String, CaseIterable, Identifiable {
underlineColor,
strikethroughColor,
strokeColor,

actionCopy,
actionDismissKeyboard,
actionFontSizeIncrease,
Expand Down Expand Up @@ -55,17 +55,17 @@ public enum RTKL10n: String, CaseIterable, Identifiable {
menuShare,
menuShareAs,
menuText,

highlightedRange,
highlightingStyle,

pasteImage,
pasteImages,
pasteText,
selectRange,

setAttributedString,

styleBold,
styleItalic,
styleStrikethrough,
Expand Down
Loading
Loading