-
-
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.
- Loading branch information
1 parent
21ba8c3
commit 5a868ee
Showing
36 changed files
with
537 additions
and
146 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
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
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
43 changes: 43 additions & 0 deletions
43
Sources/RichTextKit/Component/RichTextViewComponent+Line.swift
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,43 @@ | ||
// | ||
// RichTextViewComponent+Line.swift | ||
// RichTextKit | ||
// | ||
// Created by Daniel Saidi on 2024-02-16. | ||
// Copyright © 2024 Daniel Saidi. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
#if canImport(UIKit) | ||
import UIKit | ||
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst) | ||
import AppKit | ||
#endif | ||
|
||
public extension RichTextViewComponent { | ||
|
||
/// Get the line spacing. | ||
var richTextLineSpacing: CGFloat? { | ||
richTextParagraphStyle?.lineSpacing | ||
} | ||
|
||
/// Set the line spacing. | ||
func setRichTextLineSpacing(_ spacing: CGFloat) { | ||
if richTextLineSpacing == spacing { return } | ||
guard let storage = textStorageWrapper else { return } | ||
let range = lineRange(for: selectedRange) | ||
let style = NSMutableParagraphStyle( | ||
from: richTextParagraphStyle, | ||
lineSpacing: spacing | ||
) | ||
style.lineSpacing = spacing | ||
storage.addAttribute(.paragraphStyle, value: style, range: range) | ||
} | ||
|
||
/// Step the line spacing. | ||
func stepRichTextLineSpacing(points: CGFloat) { | ||
let currentSize = richTextLineSpacing ?? 0 | ||
let newSize = currentSize + points | ||
setRichTextLineSpacing(newSize) | ||
} | ||
} |
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
Oops, something went wrong.