Skip to content

Commit

Permalink
Revert back
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikBucher12 committed Feb 22, 2024
1 parent a836467 commit f525669
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import AppKit
#endif

public extension RichTextViewComponent {

public var richTextAlignment: RichTextAlignment? {
guard let style = richTextParagraphStyle else { return nil }
return RichTextAlignment(style.alignment)
}

/// Set the text alignment.
func setRichTextAlignment(_ alignment: RichTextAlignment) {
if richTextAlignment == alignment { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import AppKit
public extension RichTextViewComponent {

/// Get the paragraph style.
var richTextParagraphStyle: NSMutableParagraphStyle? {
richTextAttribute(.paragraphStyle)
/// We need to get paragraph style from text storage because attributed string
/// doesn't inherit those attributes from storage. It simply doesnt mirror.
/// Appears like a bug on Apples side.
public var richTextParagraphStyle: NSMutableParagraphStyle? {
textStorageWrapper?.richTextParagraphStyle(at: selectedRange)
}

/// Set the paragraph style.
Expand All @@ -29,8 +32,6 @@ public extension RichTextViewComponent {
/// selected paragraphs. If many paragraphs are selected,
/// it will only affect the first one.
func setRichTextParagraphStyle(_ style: NSParagraphStyle) {
defer { richTextAlignment = RichTextAlignment(style.alignment) }

let range: NSRange
if multipleSelectedLines() {
range = safeRange(for: selectedRange)
Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Component/RichTextViewComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public protocol RichTextViewComponent: AnyObject,
var mutableAttributedString: NSMutableAttributedString? { get }

/// Get the text alignment.
var richTextAlignment: RichTextAlignment? { get set }
var richTextAlignment: RichTextAlignment? { get }

/// The spacing between the text view's edge and its text.
var textContentInset: CGSize { get set }
Expand Down
3 changes: 0 additions & 3 deletions Sources/RichTextKit/RichTextView_AppKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ open class RichTextView: NSTextView, RichTextViewComponent {
/// The image configuration to use by the rich text view.
public var imageConfiguration: RichTextImageConfiguration = .disabled

/// Get the text alignment.
public var richTextAlignment: RichTextAlignment?

// MARK: - Overrides

/// Paste the current pasteboard content into the view.
Expand Down
3 changes: 0 additions & 3 deletions Sources/RichTextKit/RichTextView_UIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ open class RichTextView: UITextView, RichTextViewComponent {
/// Keeps track of the data format used by the view.
private var richTextDataFormat: RichTextDataFormat = .archivedData

/// Get the text alignment.
public var richTextAlignment: RichTextAlignment?

// MARK: - Overrides

/**
Expand Down

0 comments on commit f525669

Please sign in to comment.