Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested lists #991

Merged
merged 15 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion react-native-aztec/ios/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "wordpress-mobile/AztecEditor-iOS" "1.6.3"
github "wordpress-mobile/AztecEditor-iOS" "1.6.4"
2 changes: 1 addition & 1 deletion react-native-aztec/ios/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "wordpress-mobile/AztecEditor-iOS" "1.6.3"
github "wordpress-mobile/AztecEditor-iOS" "1.6.4"
13 changes: 10 additions & 3 deletions react-native-aztec/ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class RCTAztecView: Aztec.TextView {
}

private func cleanHTML() -> String {
let html = getHTML(prettify: false).replacingOccurrences(of: "\n", with: "")
let html = getHTML(prettify: false)
return html
}

Expand Down Expand Up @@ -289,7 +289,7 @@ class RCTAztecView: Aztec.TextView {
}

private func interceptBackspace() -> Bool {
guard selectedRange.location == 0 && selectedRange.length == 0,
guard isNewLineBeforeSelection() || (selectedRange.location == 0 && selectedRange.length == 0),
let onBackspace = onBackspace else {
return false
}
Expand All @@ -299,6 +299,13 @@ class RCTAztecView: Aztec.TextView {
return true
}

private func isNewLineBeforeSelection() -> Bool {
guard let currentLocation = text.indexFromLocation(selectedRange.location) else {
return false
}

return text.isStartOfParagraph(at: currentLocation)
}
override var keyCommands: [UIKeyCommand]? {
// Remove defautls Tab and Shift+Tab commands, leaving just Shift+Enter command.
return [carriageReturnKeyCommand]
Expand Down Expand Up @@ -326,7 +333,7 @@ class RCTAztecView: Aztec.TextView {
(start, end) = (end, start)
}

var result: [AnyHashable : Any] = packForRN(getHTML(prettify: false), withName: "text")
var result: [AnyHashable : Any] = packForRN(cleanHTML(), withName: "text")

result["selectionStart"] = start
result["selectionEnd"] = end
Expand Down