diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ac2c6023e..a37d91281 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,10 +6,22 @@ Until then, deprecated features may be removed in the next minor version. +## 0.7.3 + +This version makes keyboard toolbar menu prefer fixed menu order. + + + +## 0.7.2 + +This version adjusts the tweaks the new color picker component a little. + + + ## 0.7.1 This version tweaks the new color picker component a little. - + ## 0.7 diff --git a/Sources/RichTextKit/Data/RichTextDataReader.swift b/Sources/RichTextKit/Data/RichTextDataReader.swift index be8bbabd0..7b7bfbcfb 100644 --- a/Sources/RichTextKit/Data/RichTextDataReader.swift +++ b/Sources/RichTextKit/Data/RichTextDataReader.swift @@ -59,7 +59,8 @@ private extension RichTextDataReader { func richTextArchivedData() throws -> Data { try NSKeyedArchiver.archivedData( withRootObject: richText, - requiringSecureCoding: false) + requiringSecureCoding: false + ) } /** diff --git a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbarMenu.swift b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbarMenu.swift index a0fdd1d39..7bc5ad9af 100644 --- a/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbarMenu.swift +++ b/Sources/RichTextKit/Keyboard/RichTextKeyboardToolbarMenu.swift @@ -15,8 +15,7 @@ import SwiftUI The glitch is that the menu label can be incorrectly offset vertically, beyound the bounds of the menu. If that happens, - use this view instead to ensure that the label is correctly - positioned. + use this view to ensure that it's correctly positioned. */ public struct RichTextKeyboardToolbarMenu: View { @@ -40,7 +39,50 @@ public struct RichTextKeyboardToolbarMenu: View { } label: { label().opacity(0) } + .preferesMenuOrderFixed() .background(label()) } } + +private extension Menu { + + @ViewBuilder + func preferesMenuOrderFixed() -> some View { + if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) { + self.menuOrder(.fixed) + } else { + self + } + } +} + +struct RichTextKeyboardToolbarMenu_Previews: PreviewProvider { + + @ViewBuilder + static var buttons: some View { + Button("1") {} + Button("2") {} + Button("3") {} + } + + static var previews: some View { + RichTextKeyboardToolbarMenu { + if #available(iOS 15.0, *) { + Section("Title") { + buttons + } + Section { + ControlGroup { + buttons + } + } + } else { + buttons + } + } label: { + Label("Menu", systemImage: "ellipsis.circle") + } + + } +} #endif