Symfony 3 - CKEditor does not save correctly in the database - database

I have a very strange problem with CKEditor on Symfony 3.4
When I create a new line in my database, via the CKEditor utility, I write everything I want, I make the layout, I add images. Everything is OK.
But when I validate, to save the HTML format of what I typed, in my database, it happens that it does not record everything.
Either he takes away text, images, or both.
And I have this since I configured the bundle FOSUserBundle.
I write my text
I check the source code
I look at what has been saved in the database
And the rendering on my site

Related

How do I save rich text editor data to DRF - postgresql database and display in React

I want to develop a blog application with Django backend and React frontend. I shall be using Postgresql.
I want to use a rich text editor like Quill to write the blog article. My questions:
I heard that article written in a text editor needs to be converted to HTML before saving in the database. If so, how do I do this in Django Rest Framework?
How do I present the article keeping the same style and formatting in the frontend from the database?
Say, I include multiple photos in the article. How do I save all the photos in the database? i.e. what should be the schema then?
I want to have my doubts clear before I jump in.
I'm also doing the same thing at the moment. For your answers :
In DRF, the simplest way to post the data is by using Textfield in your model. Rich text field (with Tags) will be stored in the Postgres. In the Admin page or the DRF API you'll see something like this
Then, to re-render it to the front end, you can use any HTML Parser library. for example I'm using "react-html-parser" that simply convert the rich text into the defined styling.
As for Image, this is a bit tricky, and I havent done this part myself but what i could think of right now is you would create another model & end points to store the images.
when sending the post request to the django, you would convert the base file path/url from the front end to back end. example :
original > http://localhost:3000/image/efewf23r.jpg
new (django) > http://localhost:8000/media/img/img_model/efewf23r.jpg
then do a second post request to the image itself and make sure django would rename the the file as per what we set above.
Let me know if you found a better solution.
It's been long since I posted this question. After that, I have gained enough working knowledge to make Quill.js (the rich text editor I'm using) work with React.JS, or, in my case Next.JS. So, this is focused on Quill.js only. The Quill npm package more specific to ReactJS is react-quill. I am presenting it as beginner friendly as possible.
A built-in function is provided with Quill: editor.getHTML(). editor is the current editor instance, where one types the content. This method generates the innerHtml of the content one prepares in the editor.
To save it to the databse, simply POST it to your back-end. But you must sanitize this innerHtml before passing it to the database. Can't say about server-side but I had to do this sanitization on the client-side. One good package is DOMPurify. You need to save this to the database if you want to present it in the same manner as it was typed in the browser.
The first point also provides the solution to my 2nd question. But one important point: The content one writes in Quill editor is also available as a JSON like format called quill-delta. You can get the delta with the function editor.getContents(). You need to POST it to the database if you want to edit the content in a later time.
To edit, you need to get this delta from the database and then initialize Quill editor with this delta in the value attribute.
For example, the text in orange is the delta representation of the text in the editor:
codepen source.
There is another function editor.getText() which extracts all the text from the editor.
Photos. Generally in Quill, you simply put the photo in the editor and Quill generates a base64 encoded delta for the photo. It's this easy. You don't need to worry about separate image fields.

How to migrate webform submissions data from one drupal to another

Hello, I wonder if there is any way to migrate the records of a Webform (data submissions) of a site in Drupal 7 to a previous copy of the same site.
My form includes text fields, images and files, and am aware that the records of the form are not nodes.
For this reason, modules as 'Node Export' do not work (although I tried anyway).
Could anyone guide me to find the solution?
Or give me a place to start?
Have you given Migrate Webform a try yet?
From the project page
It will migrate all nodes of the webform node type (with the default
D6 fields using migrate_d2d backend), all the configuration* of the
webform's settings, the form components, email destinations,
submissions and associated submission data, in addition to any
validation configuration you have (from webform_validation module). It
grabs the "last downloaded" data too, in case your users were
downloading sequential batches since the last time they were on the
site.
Try Webform Import.
Allows delimited data files to be imported as submission (results)
into webforms.
This is useful for importing submissions from other systems in to
Webform. Can also be used to Edit submissions via Export / Import as
long as the CSV has the SID column filled.

Database search field database

I'm looking for a way to create a search box in wordpress, where visitors can search a number from the database. Is this possible? I have several package numbers in my database. I want to give my visitors the ability to search for their package number and request the information that comes with the number.
What you want to do can be done.
I suggest a different approach than using wp-exec. (I just looked at wp-exec website, and that plugin was created for WordPress 1.5, which means it hasn't been updated in about 5 years).
The content you want to display exists entirely outside of WordPress. I suggest you use a custom page template - see
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
In this case you would not use WordPress posts or pages or custom post types. On the custom page template you would write (or have written if you don't have the knowhow to do it yourself) PHP code to extract the info from the database and display it on a page.
For pages like that you would be using WordPress only as a container within which to display the results - they custom page would appear in the site Nav, The page of results would use the site's theme to display so it looks like the rest of the site.
But the code to display from the database would not use the WordPress loop. It would be PHP / MySQL data retrieval and display code.
I really doubt you will find a plugin that lets you display results from an external database, formatted the way you want them to appear. The reason is every external database is different, has different tables and table structures. And no two sites will want the external data visually displayed in the same way. So there is little generalization to encapsulate in a plugin as everyone wants it different.
I've created pages on some sites along the lines of what you want to do thus I know it can be done. But it requires writing custom code.

How to create a file and make it downloadable in GWT?

I want to export the data in a celltable to a CSV file. I understand this must be done in the server side. I'm a bit lost on how to create a file, write the lines and then make the client download it.
One it's served, it could be downloaded automatically or by a "Download" button, is the same.
If you just want to generate file and serve it directly you can create a servlet and hit the servlet url in a Window, You may want to take the same datasource and use it at the server side to convert it into a csv. Please follow along the steps as described in (Download a generated pdf from client) and for downloading that from GWT Window follow (How to download a file via a button click i GWT?),

ExtJS 3 export textarea content to a text file

I need to export the contents of an ExtJS TextArea to a text file. I searched around the documentation but I didn't find anything related to a textarea. Is this possible?
It would be also ideal to prepare the filename as well together with the ability to export the textarea content to the file.
Help is appreciated.
Thanks
You can't just save something from JS file into any place on user's local computer file system. It's huge security hole and it's just doesn't work this way. You have couple options however:
Send this information to your server and provide user with a link to a file. User clicks that link server will respond with the information - browser saves that data. You can even make so content will automatically be downloaded by the browser (well, by most of them anyway)
Or you can ask user to right click and copy this information into the clipboard.

Resources