struct ContentView: View {
   @State private var text: AttributedString = ""
   @State private var selection = AttributedTextSelection()

   var body: some View {
      VStack {
         Button(action: {
            text.transformAttributes(in: &selection) { container in
               container.font = .body.bold()
            }
         }, label: {
            Image(systemName: "bold")
         }).buttonStyle(.glass)
         
         TextEditor(text: $text, selection: $selection)
            .padding(10)
            .scrollContentBackground(.hidden)
            .background(.gray.opacity(0.2))
            .padding(20)
      }
   }
}