Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,32 @@ class EditorSelection(private val editorView: ReactNativeRichTextEditorView) {
shouldValidateStyles = true
}

if (isZeroWidthSelection()) {
editorView.setSelection(start + 1)
return
}

if (!shouldValidateStyles) return

validateStyles()
emitSelectionChangeEvent(editorView.text, start, end)
}

private fun isZeroWidthSelection(): Boolean {
if (start != end) {
return editorView.text?.substring(start, end) == "\u200B"
}

val isNewLine = if (start > 0 ) editorView.text?.substring(start - 1, start) == "\n" else true
val isNextCharacterZeroWidth = if (start < (editorView.text?.length ?: 0)) {
editorView.text?.substring(start, start + 1) == "\u200B"
} else {
false
}

return isNewLine && isNextCharacterZeroWidth
}

fun validateStyles() {
val state = editorView.spanState ?: return

Expand Down
Loading