issues while re-editing text using open-WysiWyg editor - wysiwyg

I am using openWysiWyg editor in my website. This is attached to a text-area where I can type in the content and the content is then saved to some php text file with the html tags intact. In the view page on my site i directly include this php file and everything works fine.
Recently I got requests to have some facility to re-edit the already submitted text. For that, I am using the same editor attached to a textarea and I read the contents of the file and pass it to the textarea as . The content get loaded in to the textarea and everything is fine excpet the following issue.
If i try to re-edit something like "& lt ;pankaj & gt ;" - upon loading this content in the editor it gets converted to "< pankaj >< /pankaj >" upon submitting the new changes.
So I am having two issues - why "& lt ;" is getting converted to '<' and why is this auto-completion of tags happening.
I figured out the editor does the following steps :
take textarea.value in some string
use document.write() to copy that value to the texarea's div which in itself is a iframe.
upon submitting it takes object.innerHTML to get the contents and then I save it to the disk
the above issues doesnt happen for text - "i & lt ; 5".

why "& lt ;" is getting converted to '<'
The editor is disabling the escape character < and replacing it with the literal <
why is this auto-completion of tags happening.
The editor is converting the unescaped tag to valid XHTML
the above issues doesnt happen for text - "i & lt ; 5".
That is a numeric comparison, not markup

Related

Content of tags is not getting on the same line after certain point & it is getting added to the next line . How to get that content on the same line?

I am coding HTML & CSS in VS Code IDE. I have installed & enabled the prettier extension for better readability of the code & auto-indentation. but my content of tags is not going beyond that certain point on the screen & it is getting added to the next line whenever I save my code by Ctrl +S (example: see the last paragraph tag). How to get that content on the same line?
You shouldn't use Prettier if you don't need this behavior. That's what Prettier does: splits lines that are too long. See here https://prettier.io/docs/en/index.html

JasperReports and Microsoft Word - justified text align

I have jrxml report, which gets exported into .docx format,
I have static text resources (.properties) with "\n" or "<br>" signs in values, like so:
In jasperreports 'preview' tab it looks ok:
But when .docx format is used...:
I figured out that when you paste pilcrow/paragraph (by pressing enter key) in word itself,
justified alignment works ok,
but with <br> or \n jasper inserts new line (shift enter equivalent) and it breaks everything.
May be someone knows what could be done.
Thanks!
Found the solution:
To brake row I use tab/newline ( <br> via HTML or \t\n via Java),
Text before tab/newline is aligned to the left border, text after is still justified well along the page.

from sql, php generating msWord need to show a carriage return?

My PHP generates a Word document, but it will not render carriage returns. My CKEditor translates a carriage return into either,
<br>, or <div>asdf</div>
When the Word document is created, it will display those HTML tags, so I strip them out. What replacement code, character, ascii, or tag can I use so that when the page is rendered, it shows the text like it did in the Editor?
Current example - if you have the text "Don't jump off the" [then hit Enter, so that the next word is below it]...
"cliff." Instead, currently, that gets saved into SQL as:
Don't jump off the <br>cliff.
Don't jump off the <div>cliff</div>.
...depending on which browser is used. In the msWord output, any tags left in the content [exceptions to strip_tags function] get displayed literally in msWord. Or, if I replace the tags with ASCII 
 it displays that literally, too. Not sure if this helps, but this is defined at the top of my php report_generator.php file:
require_once '/var/www/PhpWord/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
include "/var/www/ncpcphp/NCPC_PHP_Functions.php";
DEFINE("WRITEtoFDOCS", "NO");
DEFINE("FDOCSDIRECTORY", "Contract Attachments");
DEFINE("MIMETYPE","application/vnd.openxmlformats-officedocument.wordprocessingml.document" );
Help - what can I use to cause the output to show the carriage return?
Thank you, Cindy. Your answer is a piece of the solution. My CKEditor saves carriage returns as either
<br>, <br />, or <div></div>
depending on which browser is used Chrome[div] or Firefox[br] - that goes into my msSQL. Yet, if my editor has turned-on an "Enter filter" [keycode-13] in order to prevent someone from enter-editing a [[Placeholder]] (ckeditor read-onlyplugin) then saved editor text strips out the Enter. So, I did this: kept in the enter filter because it is necessary, then after the text carriage returns are saved as br's or div's, when I run my report generator, I replace
<br>, <br />, and <div></div>
with "\n" like you said. Then I explode the text variable like this:
$show_cad = explode("\n", $show_cad);
foreach($show_cad as $line) {
$section->addText(htmlspecialchars($line));
}
The code in the editor needed to filter out the Enters only when Enter is pressed in the [[Placeholder]] plug in is more complex, and I got largely from CKEditor themselves. They request that I do not post their full solutions, but if you like I could show you pieces of it. Basically, I had to register the Placeholder widget. Then when Enter is pressed, it checks if the context is with Placeholder. If so, filter the Enter [then it disappears from the saved editor text], but if Enter is pressed elsewhere, it gets saved and used properly.
Thank you for your help!

Keep § when pasting from word

I'm trying to paste content from a word doc into a tinymce instance. The content contains the § (paragraph) character, but TinyMce changes it into an li tag.
Is there a way to config TinyMce to allow special characters like §?
What you are seeing is behavior around the Paste plugin when a sentence starts with that character.
When it starts with that character the Paste plugin treats that like a list element. If the character is anywhere other than the first character TinyMCE does not create a list element.
The best thing to do is to open a bug report on the issue tracker for TinyMCE so the developers are aware of this issue.
https://github.com/tinymce/tinymce/issues

tinymce removes line breaks so all text is in a continuous chunk with no paragraphs

I'm using TinyMce textarea editor and have a problem. As you probably know Tinymce transforms a standard html textarea into a rich text editor.
On our 'edit listing' page we call up some text from our db for the user to edit (previously in a standard textarea, now in the tinymce textarea.
Previously the standard textarea would preserve linebreaks and the user would get several paragraphs of text in the text area, now with tinyMCE they get a huge chunk of text with no linebreaks. (I have pasted an example of an entry in our db below - as you can see it has line breaks in it by tinymce seems to be ignoring them when it displays them in the editor).
Just to clarify my issue is now that tinymce is stripping something when I submit the form, it's that when I pull text (that contains line breaks) from the db and populate the tinymce textarea with that data (for the user to edit) in the tinymce textarea - the text appears (in the tinymce textarea) as one massive chunk of text with my paragraphs (whereas in a standard textarea it is nicely formatted with linebreaks)
Any help on how to resolve this would be greatly appreciated - do I need to use some sort of populate() type function to put the text in, or maybe I need to replace all the linebreaks with a different special character that tinyMCE will recognise as a line break and preserve?..
Thanks in advance.
Nick
example from db:
Here is line one
Here is line two
And here is line three
Which appears in tinymce as:
Here is line one Here is line two And here is line three
I faced a similar a problem, a while back and had questions just like yours. Also I finally ended up on SE just like you.
Anyway, I think I have the solution to your problem. If you are using PHP as your server side language, then you should use nl2br() PHP function.
Suppose you have stored your content fetched from the database in a php variable. Something like this:
$content = $row['content'];
Now when displaying it on to your screen, use the nl2br() function.
echo nl2br("<p>".$content."<p>");
Now, this part inside () depends on how you want to output the data. And I will leave it to you to figure that part out.
Hope this helps.