From e6d78e80bf18b5a3ffdc54b3eaa81462c4b94899 Mon Sep 17 00:00:00 2001 From: Marcin Krzyzanowski Date: Sat, 28 Sep 2024 08:10:32 +0200 Subject: [PATCH] Add extension to NSTextLayoutFragment for isExtraLineFragment property This commit introduces a new extension to NSTextLayoutFragment, adding a computed property that checks if any of its text line fragments are considered extra line fragments. This functionality enhances text layout manipulation by providing an easy way to identify extra lines. --- ...NStextLayoutFragment+isExtraLineFragment.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Sources/STTextViewCommon/Extensions/NStextLayoutFragment+isExtraLineFragment.swift diff --git a/Sources/STTextViewCommon/Extensions/NStextLayoutFragment+isExtraLineFragment.swift b/Sources/STTextViewCommon/Extensions/NStextLayoutFragment+isExtraLineFragment.swift new file mode 100644 index 0000000..d9fc884 --- /dev/null +++ b/Sources/STTextViewCommon/Extensions/NStextLayoutFragment+isExtraLineFragment.swift @@ -0,0 +1,15 @@ +// Created by Marcin Krzyzanowski +// https://github.com/krzyzanowskim/STTextView/blob/main/LICENSE.md + +#if canImport(AppKit) && !targetEnvironment(macCatalyst) +import AppKit +#endif +#if canImport(UIKit) +import UIKit +#endif + +extension NSTextLayoutFragment { + package var isExtraLineFragment: Bool { + textLineFragments.contains(where: \.isExtraLineFragment) + } +}