Display file content into textarea using tinyMCE editor - jsf

I am developing simple page using JSF richFaces. I displayed file content into textArea using tinyMCE.
The file have more number of lines. But tinyMCE editor show all content in
single line .
Original File content is :
sample.txt
This
is
tiny MCE editor
related doubt
I read the file content using the follwing code
String content = org.apache.commons.io.FileUtils.readFileToString(fileName);
System.out.println("File Contnet is : " + content);
fileBean.setFileContent(content);
System.out.println show the content as line by line. But the editor shows the content in single line
like
This is tiny MCE editor related doubt
Help me.
Thanks in advance.

The problem is that the file content you have is "plain text" while TinyMCE is designed to edit HTML.
In HTML, whitespace, including line breaks are ignored. As such, in the editor, you will see a single line of text.
One approach to solve this would be to parse the content prior to setting it in the editor and wrap the lines in Paragraph tags. For example,
<p>This</p>
<p>is</p>
<p>tiny MCE editor</p>
<p>related doubt</p>
To do this, you could use the onBeforeSetContent Event on the editor. The documentation on the event has an example of manipulating the HTML.
Assuming you are then planning to store the HTML in the backend, then there is no need to strip this HTML out when you save the content. If you aren't then the question is why you are using TinyMCE and not a simple TextArea.

Related

Edit contents of RTF file with Powershell - Hyperlink/Mailto

Trying to update a mailto value of an RTF document with a powershell script, but it seems that the issue is RTF file related rather than Powershell related because can't get it to work when doing it by hand either:
I have previously made small find and replace changes to RTF files by finding that bit of text and changing it within the file, not using any kind of RTF library or cmdlet but just using plain string processing. With more recent RTF files updating the mailto: value in the raw file text does not seem to update the address a new message is created addressed to, and the previous value is used for the new message's TO value. The previous value not appearing in the file in plain text at that point and yet being known once the mailto link is clicked.
I am aware that RTF files have changed over time and not all of the content is purely ASCII and formatting control markup and I presume that the mailto: target is held somewhere that's not plaintext. I need to know where this other instance of the data is held in the file and a way to edit it.
mailto still showing the old email that no longer appears in plaintext in file
mailto value updated in file
Thanks for any thoughts or suggestions for things to try next!
Kind regards,
Oscar
I am able to update html and txt files just fine, but more recently RTF files are seemingly not showing the updated values because somehow they are storing the hyperlink target in a second place in the file that is not human readable. Updating other elements just by changing the human-readable instances of them in the file seems to work fine, just not the hyperlink 'mailto:' section now. Updating the link in word processor causes the human-readable 'mailto:' section to be updated when viewed in a text editor, but updating the value in a text editor and then opening it in the word processor does not show the update. So it seems to be storing the value in multiple places and the plain text version is not used in the event they're different, in so far as I've established.
Perhaps there is an RTF cmdlet or library that lets you edit the binary portion (or whatever alternate location it's held in) of the RTF file, or it would be easier to create the RTF version of the file from the properly updated HTML version. Open to ideas!

How come my textview does not create a line break when setting text, even when \n is used?

I'm using the Kotlin language on Android Studio. I created a method where the contents of a txt file I saved get displayed in a textview.
textView.setText(stringBuilder.toString()).toString()
In this txt file, there are line breaks that have been created using \n when creating the file in the first place, but it does not appear when it's in the textview. When I look at the file itself, all the lines are formatted the way they should be, but never are in the textview. What can I do to fix this?
You should use maxLines and minLines attributes in your XML, for example:
android:maxLines="6"
android:minLines="2"
EDIT :
just don't forget to set the maxLines bigger than the biggest posibility data.

Can sublime 3.0 convert display from plain text to source color scheme automatically?

I'm little new to Sublime, wanted to know if there is a way to change display in sublime-3.0 from plain text to source colors automatically (i.e. Sublime should keep source colring from where code was copied and pasted like- HTML or XML or Java code) without I changing it manually.
Thanks in Advance!
Sublime Text already does this for some languages, like XML.
It works when you have a blank document that is set to Plain Text format (i.e. you open a new tab), and paste something in whose first line can be identified to be a specific language, using regular expressions.
For XML, it looks for an XML prolog or an XML element with a namespace. Regex
For HTML, it looks for a HTML doctype.
It currently doesn't support Java - I guess it's not easy to come up with a regex that would match only the first line of a Java file and not a C# file, for example. If you do have some ideas, you can use https://packagecontrol.io/packages/PackageResourceViewer to edit the relevant .sublime-syntax (YAML) file and add a first_line_match in.
You may also find the following packages helpful:
https://packagecontrol.io/packages/AutoSetSyntax
https://packagecontrol.io/packages/ApplySyntax
Extra note: these "first line matches" also apply when opening files that aren't automatically matched to a syntax by the file's name/extension.
There might be a better way, but I've done it with the Package control ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X). Search for Package Control: install Package, press Enter and then search whatever package you need.
After installing the SCSS package, I'd get the HTML colouring as well.

How to force content editor not to cut my html code?

I have the following problem while trying to integrate Lightbox and SPS2010. All done with scripts and styles and it really works.
I create new list element and write code in internal text editor in HTML mode:
image #1
after saving my code enternal editor parse it and cut out data-lightbox="image-1" so i get only image #1
Is there any possibility to avoid parsing? Or aletrnative variant to achive my goal, e.g. template or smthng else?
Whan i put my code in master page under logo lightbox works perfectly.
Thanks in advance for any advice.
Create a text file with the html content you want to add (in your case <a href="SiteAssets/..)
Upload this file somewhere onto your sharepoint site (for example into SiteAssets library).
Go to content editor webpart, edit it and in "Content Link" section add a url to your text file.
Remove all text from internat text editor.
Save and problem solved, content editor will not change anything in your text file and will always load its content as required.
The content editor is notorious for stripping out markup it doesn't like. Put markup in external file.

How to style a yaml file?

I have a yaml file from which pdf files are created in my system- I don´t really know the first thing about yaml, but have hacked the file enough to get what I want.
Now I need to write bold text inside a line of normal text, but yaml writes normal html tags as text...so hence my question...How could I write bold text inside a line of normal text?
I have read about css styling but I haven´t got this far yet.
thanks for any tips,
Rob

Resources