Skip to content

Commit

Permalink
First commit nothing more.
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-chanch committed Mar 5, 2024
0 parents commit 36bbf4e
Show file tree
Hide file tree
Showing 8 changed files with 814 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
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
14 changes: 14 additions & 0 deletions Package.resolved
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
}
31 changes: 31 additions & 0 deletions Package.swift
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"]),
]
)
30 changes: 30 additions & 0 deletions Sources/QuillSwiftUI/Extension/UIApplication+.swift
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)
}
}
32 changes: 32 additions & 0 deletions Sources/QuillSwiftUI/QuillEditorBase.swift
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
}
}
35 changes: 35 additions & 0 deletions Sources/QuillSwiftUI/QuillEditorView.swift
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)
}
}
Loading

0 comments on commit 36bbf4e

Please sign in to comment.