TinyMCE editor does not keep the font family format when copy-pasting from an external document - tinymce

Even though I've set the parameter paste_enable_default_filters = false, seems like there is a bug in TinyMCE editor or I'm missing something. It actually keeps most of the text format when I paste a text from an external document.
However, I've a text in a Word document; it's in Times New Roman format. But when I copy-paste it into the editor, it only paste 1 line as Times New Roman, the rest is has been formatted to the default font family.
Why is this happening, why it only paste 1 line as in Times New Roman format while the rest is also in Times New Roman format? I'm open to any ideas.

Related

C# Word OpenXml SDK - Adding text to a run trims spaces

I'm trying to add text runs to an existing paragraph in Word using the OpenXml SDK, but every time I do this it ends up "trimming" the text which I add.
For example
Run newRun = newRun();
newRun.AppendChild(new Text("Hello "));
paragraph.AppendChild(newRun);
Run newRun = newRun();
newRun.AppendChild(new Text(" World"));
paragraph.AppendChild(newRun);
// the resulting paragraph contains "HelloWorld" as the text
I've also checked the XML of the resulting Run which gets generated, which clearly includes the "space" character:
<w:t xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">Hello </w:t>
I've tried injecting '\u0020' unicode values, as well as an "empty" run which just contains a single space, but nothing seems to work.
Does anyone know the trick to this?
Rolling my eyes at how typical that I find the answer 5 minutes after posting (having been trying for hours)
The answer is to add the XML xml:space="preserve" attribute to the Text element, otherwise spaces are trimmed.
newRun.InnerXml = $"<w:t xml:space=\"preserve\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">{text}</w:t>";

How VSCode choose the font from the given font list in editor.fontfamily?

When I open the VSCode editor.fontfamily setting, I found there is a list of font family in the input field. So I want to know that how VSCode choose the font from the given font list in editor.fontfamily?
Does it choose font following descended priority, and what is the stategy? Or the font in different locations have different effects?
Thanks.
The "list" is more of a set of fonts, where the first one is the preferred font, the next one being a fallback, and so on. It's not an actual list as far as a JSON object goes, it's just a string that's comma delimited.
{
"editor.fontFamily": "Consolas, 'Courier New', monospace",
// first second third
}
You can test this out by simply switching around the fonts and saving the file to see how Visual Studio Code reacts. If you put in a bogus font name as the first item in the set, when Visual Studio Code can't find the font, it will fallback to the next one. On Windows, if you supply nothing but invalid fonts, it looks like the ultimate fallback is Times New Roman (or an extremely similar looking font):

how to extract text by style in openoffice

I have an openoffice text using different styles. I need to extract all text in one style as a text .txt file (but not including text marked in the other styles). How can this be achieved?
I tried to mark other styles as hidden and save as .txt, but the result contains all text, not only the one which is visible. If I save as .pdf and then cut and paste the text from I get what I need, but this seems a roundabout solution and I am certain a better one exists.
To select all text with a certain paragraph style, go to Edit -> Find & Replace. Expand Other options and check Paragraph Styles. Then select the style name to Find and press Find All.
Now close the dialog. Copy and paste to a text editor such as Notepad (depending on your operating system). Then save the text file from the text editor.
For character styles, this will not work, so use AltSearch.

How can I output the code for my model into a word document without taking a screen shot?

I want to include an example of my model code within my project report. I have tried taking a screenshot of my code but it is just too long to be legible. I am therefore wondering if it is possible to output an image of my model code that has not been minimised or cut up into a word document for annotation?
(I assume the reason you don't just copy and paste is that you want to preserve the colors?)
Use “Save as Applet” on the File menu. From the resulting HTML file, cut out the applet part and just keep the code part.
Direct support for "Save as HTML" is coming in NetLogo 6.0; see https://github.com/NetLogo/NetLogo/issues/645.
If Seth guessed wrong and you just need a monospace font, you can just copy (ctrl-A,ctrl-C) in the Code tab, paste into your Word document, and set the font to any monospace font (like Courier New).
If Seth guessed correctly and you want syntax highlighting, you can get the Vim syntax file, open your NetLogo file in Vim, select the code range, and then use Vim's TOhtml command. You can then read this HTML file into your Word document.
Note that using Word for reports involving code is a terrible idea: the code will immediately be out of sync, as soon as you make further changes. Instead, learn LaTeX use the listings package to read your code into your document.

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.