CKEditor5 - Source formatting / layout - ckeditor

I've recently switched from CKE4 to CKE5 and note a slightly annoying side-effect with source formatting.
If typing a few short lines, the editor applies paragraph tags, which is fine, but upon saving to our db for example, all lines are joined into one, where as CKE4 kept them in nicely separated.
With CKE4 :
<p> Hello World </p>
<p> Testing 12345 </p>
With CKE5
<p> Hello World </p><p> Testing 12345 </p>
Is there a parameter to change this ?
thanks in advance

I've handled this database side using replace and adding in line break - seems to work well now.
SET #myField= replace(#myField,'</p>','</p>' + (CHAR(13) + CHAR(10)) + (CHAR(13) + CHAR(10)))

Related

( Laravel ) Break lines not working ; Balise aren't displayed anymore but it won't start a new line

I'm trying to break a line but it's always displayed whatever I do so I guess I'm doing something wrong.
Here is my line from my php file
But it's displayed like this :
My site is designed to help content creators on the web, create a free account and start \nmaking money now.
Can you help me please ?
Replace \n with <br>
Use <p></p>
My site is designed to help content creators on the web, create a free account and start making money now
Use CSS white-space property for \n (example)
try to use <br> on blade, and if you use {!! !!} i think that must be inner html inside your string. cmiiw
You can save your html text as variable like this
$subtitle_welcome = "<p>My site is designed to help content creators on the web, create a free account and start </p> <p> making money now.</p>";
OR
$subtitle_welcome = "My site is designed to help content creators on the web, create a free account and start <br/> making money now.";
And you have to show in blade
{!! $subtitle_welcome !!}

How to define a link in part of an i18n Thymeleaf / Spring message?

Using Spring / Thymeleaf i18n, I'd like to create a HTML paragraph message like "Click here", in which there is a link only for the word "here". What is the best way to do this?
The way I tried doesn't look nice and also results in a like break:
In messages.properties file:
error.generic.click=Click
error.generic.here=here
And in the HTML file:
<p th:text="#{error.generic.click}"></p><p><a th:text="#{error.generic.here}" th:href="#{/contact}"></a></p>
Answer
Your way seems okay to me. If you just want to fix the newline issue go ahead with the following one:
<p>
<span th:text="#{error.generic.click}"></span>
<a th:text="#{error.generic.here}" th:href="#{/contact}"></a>
</p>
The span will make "Click" stay on the same line as "here". However i'd just go for a link that say "Click here" instead of just "here".
For example in german you could say "Hier klicken". "Hier" would mean "here" and "klicken" would mean "click". The Problem is that the meaning for the words changed but the position didn't. You would end up with a link saying "klicken" instead of "Hier".
Not recommented
There is another approach, but it has some drawbacks. You could use:
<p th:utext="#{error.generic}"></p>
with the following messages.properties:
error.generic=Click here
The drawback on this one is that you can't use th:href anymore. I would not recomment this way. However this can be helpfull when using no th:* and just plain html tags. So i wanted to mention it.

CKEditor is modifying my HTML source - and not for the better. Any way to prevent this?

I realize there are many questions about CKEditor modifying HTML source. But none of the suggestions appear to work.
In particular, the most general suggested change:
config.allowedContent = true;
seems to help quite a bit, but a lot still gets changed.
For example, the following HTML entered in SOURCE mode gets modified.
Original:
<p><a name="top"></p>
<p>Over the course of its 2 phases the ACCRA programme has co-authored and published a large collection of reports, case studies, evaluations and working papers. These are all available to download for free here.<br>
Our resources are categorised as follows: General Programme Information | Research reports | Country case studies | Phase 1 Evaluation | Working papers| Publications in Portuguese</p>
Turns into this:
<div> </div>
<p><a name="top"></a></p>
<p><a name="top"> </a></p>
<p><a name="top">Over the course of its 2 phases the ACCRA programme has co-authored and published a large collection of reports, case studies, evaluations and working papers. These are all available to download for free here.<br>
Our resources are categorised as follows: </a>General Programme Information | Research reports | Country case studies | Phase 1 Evaluation | Working papers| Publications in Portuguese</p>
Duplicated lines and even spaces are added.
Another example:
Original:
<div style="clear: both"></div>
<p></p>
<p></p>
Becomes this:
<div style="clear: both"> </div>
<p> </p>
<p> </p>
I could go on, but you get the point.
The changed source gets rendered differently from the original. For example, rows of publications which were nicely aligned get slightly misaligned if opened and then saved in the CKEditor.
Is there a way of telling CKEditor to please leave my valid HTML source as is?
The option config.allowedContent = true; should do the trick for leaving your VALID html code intact.
But in the case that there is no valid html code it will try to correct it in order to show it correctly (that is because CKEditor is not a code writing tool but a WYSIWYG tool).
In your first example your html is not valid (<p><a name="top"></p>). The <a> tag should have a corresponding </a> end tag.
In your second example you can disable the automatic fillup of empty tags with the using the option:
config.fillEmptyBlocks = false;

Dynamically change the font size of a single character in SSRS

Using SSRS in Visual Studio 2012 I currently have the following expression in the report header.
=ReportItems!FirmName.Value
This correctly pulls the Firm name such as Client1, Client2, Client3 etc... from the body of the report.
However if ReportItems!FirmID = 600, I need the Font size of the first character in Firm name to be larger then the other characters.
This is because a particular client has a logo where the first character is larger than the others.
I tried the following expression which I know is wrong but might illustrate what I'm trying to do.
=IIF(ReportItems!FirmID.Value = 600,LEFT(ReportItems!FirmName.Value,1), "18pt", ReportItems!FirmName.Value))
So say client3 has FirmID 600 the result should be like this, you may need to run the code snippet to see what I mean...
<html>
<body lang=EN-US style='tab-interval:.5in'>
<div class=WordSection1>
<p class=MsoNormalCxSpFirst>Client1<o:p></o:p></p>
<p class=MsoNormalCxSpMiddle>Client2<o:p></o:p></p>
<p class=MsoNormalCxSpLast><span style='font-size:20.0pt;line-height:115%'>C</span>lient3</p>
</div>
</body>
</html>
I tried Ian's suggestion
which I thought was working, but I cannot yet get it to work. I can get this to work in the report body, but there are additional complications. The font size change needs to be in the Report Header, which requires referencing the report body via ReportItems! You cannot reference more than one ReportItems! in the report header or you get an error like the following
The Value Expression for the textrun Textbox12 refers to more than one report item. An expression in a page header or footer can refer to only one report item.
Yet there is one more problem and I should have clarified this in my original entry. The actual client name is like this.
Client & Associates
Both of the first letters need to be larger, but not the ampersand between them.
<html>
<body lang=EN-US style='tab-interval:.5in'>
<div class=WordSection1>
<p class=MsoNormal><span style='font-size:22.0pt;line-height:115%'>C</span>lient
& <span style='font-size:18.0pt;line-height:115%'>A</span>ssociates</p>
</div>
</body>
</html>
You can do this by creating a couple of text placeholders within the same textbox, splitting the text between these and apply a font-size expression to the first placeholder only.
See Formatting Text and Placeholders for a good overview.
In a simple example with your data:
I have a simple table to display this:
Note there are two <<Expr>> values in the last column - I have added another placeholder in this textbox.
I have split FirmName between these placeholders; in the first:
=Left(Fields!FirmName.Value, 1)
and in the second:
=Right(Fields!FirmName.Value, Len(Fields!FirmName.Value) - 1)
Even though the text is split in two expressions, it looks fine when the report is run:
Since each placeholder can have its own formatting, we can apply an expression like the following to FontSize on the first placeholder only:
=IIf(Fields!FirmID.Value = 600, "15pt", "10pt")
i.e. increase font size of the first letter for firm 600, which gives us the required results:

Escape # character in razor view engine

I am creating a sample ASP.NET MVC 3 site using Razor as view engine. The razor syntax starts with # character e.g. #RenderBody(). If I write #test on my cshtml page it gives me parse error
CS0103: The name 'test' does not exist in the current context
How do I escape '#' character?
## should do it.
Razor # escape char to symbols...
<img src="..." alt="Find me on twitter as #("#username")" />
or
<img src="..." alt="Find me on twitter as #("#")username" />
#Html.Raw("#") seems to me to be even more reliable than ##, since not in all cases ## will escape.
Therefore:
<meta name="twitter:site" content="#twitterSite">
would be:
<meta name="twitter:site" content="#Html.Raw("#")twitterSite">
use <text></text> or the easier way #:
Instead of HTML entity I prefer the use of #Html.Raw("#").
## is the escape character for # in Razor views as stated above.
Razor does however try to work out when an '#' is just an '#' and where it marks C# (or VB.Net) code. One of the main uses for this is to identify email addresses within a Razor view - it should not be necessary to escape the # character in an email address.
For the question about #RazorCodePart1 ## #RazorCodePart2, you need to the sequence:
#RazorCodePart1 #:## #RazorCodePart2
I know, it looks a bit odd, but it works and will get you the literal character '#' between the code blocks.
I just had the same problem. I declared a variable putting my text with the #.
#{
var twitterSite = "#MyTwitterSite";
}
...
<meta name="twitter:site" content="#twitterSite">
I know this question is old, but I tried all of the above and it didn't help me escape the character "#" in ASP.NET framework (MVC 5) inside a URL. Based on Terje Solem's answer though, the UTF-8 code %40 worked for me. this is the original URL I was trying to reach:
https://unpkg.com/#google/markerclustererplus#4.0.1/dist/markerclustererplus.min.js
this is what worked for me in my code:
https://unpkg.com/%40google/markerclustererplus#4.0.1/dist/markerclustererplus.min.js
this work for me
<meta name="author" content="Alan van Buuren #("#Alan_van_Buuren")">
Or yoy can use:
##Alan_van_Buuren
:D
You can use ## for this purpose.
Like var email = firstName + '\##' + domain;
I tried all the options above and none worked. This is what I did that worked :
#{
string str = #"[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}$";
}
<td>Email</td>
<td>
<input type="text" id="txtEmail" required name="email" pattern=#str />
</td>
I created a string varible and passed all the RegEx pattern code into it, then used the variable in the html, and Razor was cool with it.
just add a variable in CSHTML file
var myVariable = #"#";
and add it to your layout
<span class="my-class"><a href="#myVariale" target="_blank" >link text</a></span>
I couldn't get any of these to work inside my placeholder attribute, so I used xml special character.
<input type="text" placeholder="fex: firstname#lastname.com"/>
See more examples here.
https://www.dvteclipse.com/documentation/svlinter/How_to_use_special_characters_in_XML.3F.html
Actually # should be used with the Razor syntax Keywords or to the variable/model to bind a Value.
For Eg:
if test is assigned with value
i.e # { var test = "ABC" }
then you can get the value by settings as #test anywhere is cshtml page in html part.
otherwise, simple use as #Html.DisplayName("test")
I think in Razor view #Html.Raw() is the best solution for all version and always works for me. I have added an working example cdn URL to provide clear idea.
#Html.Raw("<script src=\"https://cdn.jsdelivr.net/npm/#popperjs/core#2.11.6/dist/umd/popper.min.js\"></script>")

Resources