-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 36bbf4e
Showing
8 changed files
with
814 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
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,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "swifterswift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/SwifterSwift/SwifterSwift.git", | ||
"state" : { | ||
"revision" : "1eab3444fa06a344a35e79540719df956ab4d4ad", | ||
"version" : "6.0.0" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
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,31 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "QuillSwiftUI", | ||
|
||
platforms: [.iOS(.v15)], | ||
|
||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "QuillSwiftUI", | ||
targets: ["QuillSwiftUI"]), | ||
], | ||
|
||
dependencies: [ | ||
.package(url: "https://github.com/SwifterSwift/SwifterSwift.git", from: "6.0.0") | ||
], | ||
|
||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.target( | ||
name: "QuillSwiftUI", dependencies: [.product(name: "SwifterSwift", package: "SwifterSwift")]), | ||
.testTarget( | ||
name: "QuillSwiftUITests", | ||
dependencies: ["QuillSwiftUI"]), | ||
] | ||
) |
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,30 @@ | ||
// | ||
// UIApplication+.swift | ||
// JERTAM | ||
// | ||
// Created by Chanchana Koedtho on 15/11/2566 BE. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
|
||
extension UIApplication{ | ||
|
||
var currentWindow: UIWindow? { | ||
connectedScenes | ||
.compactMap { | ||
$0 as? UIWindowScene | ||
} | ||
.flatMap { | ||
$0.windows | ||
} | ||
.first { | ||
$0.isKeyWindow | ||
} | ||
} | ||
|
||
func endEdit(){ | ||
self.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) | ||
} | ||
} |
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,32 @@ | ||
// | ||
// QuillEditorBase.swift | ||
// | ||
// | ||
// Created by Chanchana Koedtho on 4/3/2567 BE. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import SwiftUI | ||
|
||
public protocol QuillEditorBase: View { | ||
var customFont: UIFont? { get set } | ||
var onTextChange: ((String)->())? { get set } | ||
|
||
func customFont(font: UIFont?) -> Self | ||
func onTextChange(_ perform: ((String)->())?) -> Self | ||
} | ||
|
||
public extension QuillEditorBase { | ||
public func customFont(font: UIFont?) -> Self { | ||
var copy = self | ||
copy.customFont = font | ||
return copy | ||
} | ||
|
||
public func onTextChange(_ perform: ((String)->())?) -> Self { | ||
var copy = self | ||
copy.onTextChange = perform | ||
return copy | ||
} | ||
} |
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,35 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Chanchana Koedtho on 4/3/2567 BE. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
public struct QuillEditorView: QuillEditorBase { | ||
let placeholder: String | ||
|
||
public var customFont: UIFont? | ||
public var onTextChange: ((String) -> ())? | ||
|
||
@State private var dynamicHeight: CGFloat = 0 | ||
|
||
@Binding var text: String | ||
|
||
public init(_ placeholder: String = "", text: Binding<String>) { | ||
self._text = text | ||
self.placeholder = placeholder | ||
} | ||
|
||
public var body: some View { | ||
QuillEditorWebView(placeholder: placeholder, | ||
dynamicHeight: $dynamicHeight, | ||
text: $text) | ||
.customFont(font: customFont) | ||
.onTextChange(onTextChange) | ||
.padding(.bottom, 10) | ||
.frame(minHeight: dynamicHeight) | ||
} | ||
} |
Oops, something went wrong.