B4A Library CustomView RichTextEditor

OUTDATED! New Version to, have look here: RTFeditor Version 2021 | B4X Programming Forum

Hello to all forum Members,
I hope all of you are well. Looking through the forum I find the library SMMRichEditor. Playing around with it I started a new project to use this lib to build a custom view like a small word processor.

RTFEditor

Version 1.3

Updated 2021/04/6 1.3:

  • fixed minor bugs

RTFEditor1.png


Feature list:


  • Textgravity: bold, italic, underline, strikethrough, superscript, subscript
  • Text as unordered list with bullets.
  • Text as ordered list with numbers.
  • Text with a leading checkbox.
  • Align Text: left, center, right
  • Set (all Text) Textcolor.
  • Set (all Text) Textsize.
  • Set indent, outdent.
  • Undo last command/input.
  • Editor scroll up/down
  • Button/Function State color
Event: TextChanged(HTML)
Every Time the editor text changes this event is fired and returns the text as a standard string. It should be no problem to save this string to a file or database.
In addtion you may get the editor text from the global 'EditorText'.

Property:
EditorHTMLText as String
Set Text to the editor e.g. retrive text from database to editor.

Editor Panel Height as Int
Default value is 200. The height of the inner control panel (editor). if this height is greater than the controls height text will scroll.

Language: B4A

Find attached:
"RTFEditorDEMO.zip" as a B4A Demo Project
library/custom control 'RTFEditor.b4xlib'
Add the Files from "Ressources2Files.ZIP" uncompressed to the Files Directory of your Project.


NOTICE !!

  • The RTFEditor view works with the libraries shown in the picture (see attached images).
  • The editor creates the text as html formated string including html format characters.
  • The core of RTFeditor is the control SMMRichEditor. This internal control is NOT my control! Therefore I don't have access to it's source code. All SMMRichEditor Limitiations are also limiting RTFeditor functions. If you like take this link to find the SMMRichEditor lib: https://www.b4x.com/android/forum/threads/richeditor-view.66319/#content
  • If you try debug mode you will get an error that some files like Editor.html are not found. This is why in Debug mode files are not stored in the asset folder. In release mode all is good.
  • The lib file RTFeditor.B4xLib is a standard zip compressed file. To get access to the control source code rename the file to .zip uncompress it and you will get RTFeditor.bas file. Import this into a project and the code access is open
Any Comments or optimization proposals are welcome.
 

Attachments

  • RTFEditor2.png
    RTFEditor2.png
    21.1 KB · Views: 415
  • RTFEditor3.png
    RTFEditor3.png
    31.2 KB · Views: 395
  • RTFEditor4.png
    RTFEditor4.png
    30.5 KB · Views: 383
  • Libraries.png
    Libraries.png
    20.8 KB · Views: 419
  • Ressources2Files.zip
    8.8 KB · Views: 290
  • RTF_EditorDEMO13.zip
    17.4 KB · Views: 238
  • RTFEditor.b4xlib
    2.4 KB · Views: 227
Last edited:

Guenter Becker

Active Member
Licensed User
I think that you have to add the files in CopytoAssetsFolder.zip from the above link to your project's Assets (Add to IDE File tab) but even then the app crashes with a missing layout file error.

java.io.FileNotFoundException: rtfeditor.bal
Hello to you,
thank you for your comment. I edit the article and added the link to get the SMMRichEditor and added a ZIP file with additional ressources needed by the custom view. Please have a look at the files and the NOTICE section.
 

cklester

Well-Known Member
Licensed User
Language: B4A
...
Any Comments or optimization proposals are welcome.

Are you planning any cross-platform development as well? I suspect maybe SMMRichEditor is Android-only, and that's why you haven't done a B4A or B4J version... but I can hope! šŸ˜

I'm looking, right now, for a view that lets people (at least) use mark-down formatting.
 

Guenter Becker

Active Member
Licensed User
Sorry I'm only programming in B4A but I think it should be possible to transform in B4J or B4i. But that needs experts of this languages. And the Base is SMMRichEditor as I pointed out this lib is not from me! Please notice that my lib is not obfuscated or protected If anyone likes to transform it - feel free to do it.
 

Guenter Becker

Active Member
Licensed User
What save? What bring to where?
To get a clear and understandable answer make your question clear and understandable at first!
 

Almora

Active Member
Licensed User
Longtime User
I am using translation. I'm sorry.
how can we save the file. and how we can back view the saved file.
 

Guenter Becker

Active Member
Licensed User
A close look to my article says

....
Event: TextChanged(HTML)
Every Time the editor text changes this event is fired and returns the text as a standard string. It should be no problem to save this string to a file or database.
In addtion you may get the editor text from the global 'EditorText'.

>>>>>>>>>>>
use the event to save the HTML string into a string variable. save the string variable content to a database text field or a text file using standard functions.
Example: (Public global sFormatedText) sFormatedText = HTML
Property: EditorHTMLText as String
Set Text to the editor e.g. retrive text from database to editor.

>>>>>>>>>>>
Get the text from the Database column or a text file and put it into the property EditorHTMText thats all, foremating is done automatic.
Example: RTFEditor1.EditorHTMLText = oResultset.getstring("ColumnName")
 

Almora

Active Member
Licensed User
Longtime User
Hi..
Version Alpha 1.1
Updated: added scroll functionality to editor
it scrolls down when typing long text, but it doesn't scroll back up.

And
Is it possible to specify which button is active.
 

Guenter Becker

Active Member
Licensed User
Check it and changed lib. Testit it and its scrolling up and down. Please test it to. Thank you.
 

Attachments

  • RTFEditor.b4xlib
    1.9 KB · Views: 213

Guenter Becker

Active Member
Licensed User
Oh, Oh give me some timeplease to inspect that seems tom for a trial and error session.
 

Guenter Becker

Active Member
Licensed User
Hello Almora,
please look at the updated article and use the new/changed library. I tested it and now it scrolls up and down, there was an error in my scrollview setup. Also I added your whish to see what function/button is active. If you press the button and the function is active the button is green. If not it's black. Thank you for your proposal and support. Stay well.
 
Top