How could we best add save functionality to the editor?
Are we suppossed to grab te innerHtml of the DIV to which the editor is linked, sanitize that (any recommendations for that?), and store that in a text blob ourselves?
Or is there a better way to do this?
Hi Michel, hope you are well.
There is no best way to store editor content, as it depends very much on your project.
In the customer projects where I implemented the Tiny Editor, most of them saved the editor content in HTML format.
If you need to recover the text with ALL formatting, I recommend saving the content in HTML format.
If you only need the text, without editing (formatting), then you can save just the text from the editor.
In entities, we usually create an attribute of type "text", with a high value to store the html of the text that appears in the editor.
Anyway, the component itself provides two client actions to "get" the content of the editor:
Use one of these two actions to retrieve the content typed in the editor, and then just save it in a text attribute in the entity.
Hug,
Thank you, that clarifies it a bit more to me.
How do you set any previously saved content? I presume uysing the SetEditorContent or SetHTML client actions, but at what point can you call them?
I noticed there was no callback from the TinyMCE component, in order to know that TinyMCE itself is done initializing.
Also, how would one prevent the default page to be shown?
Thank you for your time and efford in this component!
Michel
To start the editor with some content, you can use the "content" field in the editor properties, directly passing the text saved in the database.
Or, you can also place the editor inside an IF, with the content pointed to the entity field, and in the IF configuration you set it to show the editor only after the table has finished loading (fetch).
Another method is also to load the blank editor, without filling in the content, and after the table loads, put the action "SetEditorContent" in the entity's "OnAfterFecth" function.
That way you already have 3 options on how to place the previously saved content inside the editor.