mirror of
https://github.com/FossifyOrg/Notes.git
synced 2026-06-11 10:09:29 -04:00
fix: clear spans on paste (#152)
* fix: clear spans on paste See: https://github.com/FossifyOrg/Notes/issues/150 * style: add empty line
This commit is contained in:
13
app/src/main/kotlin/org/fossify/notes/extensions/EditText.kt
Normal file
13
app/src/main/kotlin/org/fossify/notes/extensions/EditText.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.fossify.notes.extensions
|
||||
|
||||
import android.text.InputFilter
|
||||
import android.text.Spanned
|
||||
import org.fossify.commons.views.MyEditText
|
||||
|
||||
fun MyEditText.enforcePlainText() {
|
||||
val stripSpans = InputFilter { source, start, end, _, _, _ ->
|
||||
val sub = source.subSequence(start, end)
|
||||
if (sub is Spanned) sub.toString() else sub
|
||||
}
|
||||
filters = (filters ?: emptyArray()) + stripSpans
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import org.fossify.notes.databinding.FragmentTextBinding
|
||||
import org.fossify.notes.databinding.NoteViewHorizScrollableBinding
|
||||
import org.fossify.notes.databinding.NoteViewStaticBinding
|
||||
import org.fossify.notes.extensions.config
|
||||
import org.fossify.notes.extensions.enforcePlainText
|
||||
import org.fossify.notes.extensions.getPercentageFontSize
|
||||
import org.fossify.notes.extensions.updateWidgets
|
||||
import org.fossify.notes.helpers.MyMovementMethod
|
||||
@@ -67,6 +68,8 @@ class TextFragment : NoteFragment() {
|
||||
noteEditText = textNoteView
|
||||
}
|
||||
}
|
||||
|
||||
noteEditText.enforcePlainText()
|
||||
if (config!!.clickableLinks) {
|
||||
noteEditText.apply {
|
||||
linksClickable = true
|
||||
|
||||
Reference in New Issue
Block a user