Skip to content

Commit

Permalink
chore: Update editor with new API
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinperignon committed Apr 23, 2024
1 parent d7e42cd commit 1168c01
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 3 additions & 4 deletions Mail/Views/New Message/MailRichEditor/EditorCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class EditorCoordinator {

extension EditorCoordinator: RichEditorViewDelegate {
func richEditorViewDidLoad(_ richEditorView: RichEditorView) {
richEditorView.text = parent.body
richEditorView.html = parent.body

let editorCSS = MessageWebViewUtils.loadCSS(for: .editor)
for css in editorCSS {
Expand All @@ -47,11 +47,10 @@ extension EditorCoordinator: RichEditorViewDelegate {
}

func richEditorViewDidChange(_ richEditorView: RichEditorView) {
// TODO: Maybe we can throttle here?
parent.body = richEditorView.text
parent.body = richEditorView.html
}

func richEditorView(_ richEditorView: RichEditorView, didSelectedTextAttributesChanged textAttributes: RETextAttributes) {
func richEditorView(_ richEditorView: RichEditorView, selectedTextAttributesDidChange textAttributes: RETextAttributes) {
updateToolbarItems(for: richEditorView, style: toolbarStyle)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Mail/Views/New Message/MailRichEditor/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct EditorView: UIViewRepresentable {
}

func updateUIView(_ richEditorView: RichEditorView, context: Context) {
if richEditorView.text != body {
richEditorView.text = body
if richEditorView.html != body {
richEditorView.html = body
}
}

Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let package = Package(
.package(url: "https://github.com/johnpatrickmorgan/NavigationBackport", .upToNextMajor(from: "0.8.1")),
.package(url: "https://github.com/aheze/Popovers", .upToNextMajor(from: "1.3.2")),
.package(url: "https://github.com/shaps80/SwiftUIBackports", .upToNextMajor(from: "1.15.1")),
.package(url: "https://github.com/httpswift/swifter", .upToNextMajor(from: "1.5.0"))
.package(url: "https://github.com/httpswift/swifter", .upToNextMajor(from: "1.5.0")),
.package(path: "/Users/valentinperignon/Developer/packages/infomaniak/swift-rich-editor")
]
)
6 changes: 4 additions & 2 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ let project = Project(name: "Mail",
.external(name: "Lottie"),
.external(name: "NavigationBackport"),
.external(name: "Popovers"),
.external(name: "SwiftUIBackports")
.external(name: "SwiftUIBackports"),
.external(name: "InfomaniakRichEditor")
],
settings: .settings(base: Constants.baseSettings),
environmentVariables: [
Expand Down Expand Up @@ -105,7 +106,8 @@ let project = Project(name: "Mail",
.external(name: "Lottie"),
.external(name: "NavigationBackport"),
.external(name: "Popovers"),
.external(name: "SwiftUIBackports")
.external(name: "SwiftUIBackports"),
.external(name: "InfomaniakRichEditor")
],
settings: .settings(base: Constants.baseSettings)),
.target(name: "MailNotificationServiceExtension",
Expand Down

0 comments on commit 1168c01

Please sign in to comment.