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:
Naveen Singh
2025-07-06 12:32:59 +05:30
committed by GitHub
parent 7939ce5040
commit 0f0d3d28a7
2 changed files with 16 additions and 0 deletions

View 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
}

View File

@@ -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