Closed tised closed 5 years ago
Just found in sources private fun editorLoaded(context: Context) { isLoaded = true
paddingToSetOnStart?.let {
setPadding(it.left, it.top, it.right, it.bottom)
paddingToSetOnStart = null
}
(context as? Activity)?.runOnUiThread {
setEditorFontFamily("serif")
}
}
I think it would be better if you will move setEditorFontFamily("serif")
to a variable which can be changed over attributes while RichTextEditor initializes, and by default it will have "serif"
You're right in both regards: There should be a way to set default font family and - even though not mentioned directly - editorLoaded() method should be overrideable.
The reason why it sometimes works and sometimes not should be a classical race condition: Sometimes the async editor loading is faster (then it works), sometimes your method call (then it doesn't work).
As I haven't found a senseful way how to set default font family on editor (if you know any, please let me know), I did two things:
Both changes are on branch release/2.0.x (https://github.com/dankito/RichTextEditor/blob/release/2.0.x/RichTextEditorAndroid/src/main/kotlin/net/dankito/richtexteditor/android/RichTextEditor.kt).
If you think they are senseful I can release version 2.10 so that they are publicly available.
I think your solution is pretty good! Release 2.10, please
Just released version 2.0.10. Should be visible at Maven Central within two hours.
Just let me know if suits your needs so that I can close this issue.
Hello! Yes, seems it working, now I able to set "sans-serif" as default
So the thing is, I want to set as "default" font for input - sans-serif. I found method
editor.setEditorFontFamily("sans-serif")
but it sets only for preview mode (as I understand) After saving note,<font>
tag not included into HTMLAlso, I tried to use
editor.javaScriptExecutor.executeEditorJavaScriptFunction("setFontName('sans-serif')")
on screen load, but sometimes it works, sometimes not My guess is that pointer goes outside of tag on screen open, or something like this Can you help me with that ?P.S. when I selecting font from
SetFontNameCommand
all works perfectly, but I do not understand whyeditor.javaScriptExecutor.executeEditorJavaScriptFunction("setFontName('sans-serif')")
not working then