TextEditorPlus

1.3.0

An enhanced version similar to `TextEditor`, aimed at maintaining consistency in its usage across iOS and macOS platforms.
jaywcjlove/swiftui-texteditor

What's New

2025-01-18T18:11:06Z
  • feat: add auto-hide scrollbars feature.

SwiftUI TextEditorPlus

Buy me a coffee CI SwiftUI Support

An enhanced version similar to TextEditor, aimed at maintaining consistency in its usage across iOS and macOS platforms.

✦ My macOS/iOS application ✦

KeyClicker DayBar Iconed RightMenu Master Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe


Installation

You can add MarkdownUI to an Xcode project by adding it as a package dependency.

  1. From the File menu, select Add Packages…
  2. Enter https://github.com/jaywcjlove/swiftui-texteditor the Search or Enter Package URL search field
  3. Link Markdown to your application target

Or add the following to Package.swift:

.package(url: "https://github.com/jaywcjlove/swiftui-texteditor", from: "1.0.0")

Or add the package in Xcode.

Usage

import TextEditorPlus

struct ContentView: View {
    @State var text = """
    Hello World
    """
    @State var isEditable = true
    var body: some View {
        TextEditorPlus(text: $text)
            .textSetting(isEditable, for: .isEditable)
    }
}

Set text weight and size:

TextEditorPlus(text: $text)
    .font(.systemFont(ofSize: 24, weight: .regular))

Set editor padding:

TextEditorPlus(text: $text)
  .textSetting(23, for: .insetPadding)

Set editor background color:

TextEditorPlus(text: $text)
  .textSetting(NSColor.red, for: .backgroundColor)

Set editor text color:

TextEditorPlus(text: $text)
  .textSetting(NSColor.red, for: .textColor)

Set editor placeholder string:

TextEditorPlus(text: $text)
    //.font(NSFont(name: "pencontrol", size: 12)!)
    .font(.systemFont(ofSize: CGFloat(Float(fontSize)!), weight: .regular))
    .textSetting("Test placeholder string", for: .placeholderString)

Manipulate attributed strings with attributes such as visual styles, hyperlinks, or accessibility data for portions of the text.

TextEditorPlus(text: $text)
    .textSetting(isEditable, for: .isEditable)
    .textViewAttributedString(action: { val in
            let style = NSMutableParagraphStyle()
            style.lineSpacing = 5
            style.lineHeightMultiple = 1.2
            val.addAttribute(.paragraphStyle, value: style, range: NSRange(location: 0, length: val.length))
            return val
    })

License

Licensed under the MIT License.

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

Last updated: Sat May 24 2025 17:24:35 GMT-0900 (Hawaii-Aleutian Daylight Time)