Paragraph returns not being acknowledged in Wordpress Advanced Custom Fields - advanced-custom-fields

I have a WYSIWYG field setup via the Advanced Custom Fields plugin.
The field itself is displaying on the frontend, but paragraph returns are not being acknowledged.
For example if I write 4 sentences with a return key pressed between each one, the resulting frontend view is just one long line of text.
If I view the backend editor in "Visual" tab I can see the paragraph returns, but if I change tab to "Text" there is no HTML "p" tags in place.
Can anyone suggest a solution?

Related

How can I get our WYSIWYG editor to stop removing HTML comments, CSS classes and inline styles?

We currently use wysihtml5-rails to let our users edit emails before they are sent but this is not working out so well for a few reasons.
I need the comments to allow for Outlook specific comments like these . All comments are being removed, currently.
I also need the CSS classes to be untouched as the editor content will be a pre-generated email that includes CSS classes. Our editor will only keep classes that are whitelisted but this is annoying as we need to update that list with every change.
Same goes for inline styles. Some of the styles in the generated email are inline instead of in classes. Those need to be kept but they are being removed.
Is there any way I can get our editor to work this way?
I found a solution but it's hacky.
I realized that the raw HTML was being stored on the page in a hidden textarea tag. Interestingly, all the elements that I needed (CSS classes, comments) were still there. But when submitting the form, the value of this textarea was replaced with the parsed results from the editor which gets sent to the server. All the comments and classes are gone from this text.
The solution was then to create a second field that takes the unparsed value from the WYSIWYG editor and sends that along. Easy in rails but just making this new field part of a form. Then the controller can choose which value to take. In my case, I renamed the existing message field to parsed_message. Then added a new message field which will hold the unparsed message.
The WYSIWYG editor we are using allows this by having a method that can be called at any time: window.email_editor.getValue(). Here the email_editor is the editor instantiated by the javascript on the page.

Google App Script. How can i get hyperlink name?

Have troubles with extracting url from text in google document. I found method getLinkUrl(offset). It works fine, but if i for example add link not directly to text but via menu item Insert -> Link i can specify some name for link, for example name, that will be displayed in text will be StackOverflow and the link is https://stackoverflow.com, so when i use method getLinkUrl() i will get hyperlink but not the name. I need to get position of this link on text, so i need to get this word StackOverflow but i didn't find corresponding method for this.
Is someone know how i can get this word or its start and end indexes?
I know about attributeIndices property which contains indexes of starting of special formatting of text and it can be used in this case, but if link is last word in paragraph, there is no any more attribute index in this array, so i can not determine length of this word.
Would be appreciate for any advice)

Create custom templates using ckeditor, tinymce or any online editor

I am not sure if the title represents what exactly I need to do, But here is the details. I am building a website using PHP that allows people to create different templates, then they should select one of them and then fill the fields to fill the placeholders. For example consider the following image
The name of the recipient could be a placeholder so some part of the template can be
Dear {recipient}
{body}
and I prepare two fields for recipient and the body and it will be replaced by the value of the corresponding field. I can do this. What I can't do is how to let the user to align the placeholders in the paper. For example there is a placeholder for the date that must be at right of the page, or any other placeholder that can be place inside the paper (same as the following image). I would like to know if ckeditor or any other editor allows me to create such template?
The structure of the template must be kept in A4 or A5 print page.
I’m having trouble understanding your question. If you're looking for templates in TinyMCE editor, I think you should try using template plugin for tinymce - there is one for wordpress. You can write your own plugin too, there was question about it.

Saving text as HTML from form

I have a form with a text field that users input text into. They can use multiple lines, put in bold text, underlined text, etc., but the text, when saved to SQL Server doesn't have any formatting saved, just the text is saved. What is the best way to save the text with the HTML so that when it gets viewed by another user and pulled up from Sql Server the HTML is saved and the formatting is saved?
Ex.
hello
Paul
This would be saved as
helloPaul
you can't see it but there are bold and carriage return html tags rapped around the text
When receiving data from the user, on the server side code, use HTML encode to safely store the data:
var inputData = Server.HtmlEncode("<strong>some data input from user</strong>"); //insert your user input data variable here
Then when displaying the data in your cshtml page, decode the data to display it as the user entered it:
HttpUtility.HtmlDecode(saveUserDataFromDatabaseVariable);
All this is assuming you have a rich text editor being plugged into the input field. CKEditor and TinyMCE are good ones.
You can use a text editor. Take a look at CKEditor. It's free and easy to use :)
Can you post some code and more details?
I have had good success with CKEditor. It is customizable, and its content can easily be saved via postback to a standard asp:TextBox.
It is possible that the editor you are using is not actually updating the input/textarea that you are using, it may be cloning the text and drawing the formatting in an overlay. You can use developer tools, or javascript, to verify this by checking the value property of the input or textarea element. If it is being saved via AJAX or javascript the code may be using the textContent or innerText properties instead of innerHTML.
I used the richtexteditor dll that's free online. it gave me a wiziwig box that the user can edit texxt in.

How to preserve the layout of textarea in the database?

I have a text area in html and a form to store the information in the database. When I click on submit, it supposed to take this text and save it in the database. For example:
"This is a text and this is a list:
1. number 1
2. number 2"
However, when I load the information from the database it looks like:
"This is a text and this is a list: 1. number 1 2. number 2"
How do I keep the layout of the textarea not changed (keep the spaces, lists, etc) without the need for the user to enter any tags.
It's being stored just fine in the database. You're outputting what was entered as plain text as HTML, and HTML ignores line breaks. You need to convert your \n characters to <br /> tags. PHP has a nl2br() function for this.
You could have them enter the data in a WSYWIG and do the work on your side to make sure it's always formatted properly - client-side users still won't have to see any tags, especially if you limit their editing options...
tinyMCE, nicEdit are two good editors