CKEditor5 setData() stripping <code> tags - ckeditor5

When I try to run
editor.setData("<p>test comment</p><code class=\"python-code\">def withCodeBlock:<br /> print('test')</code>");
The resulting editor contains the html:
<p>test comment</p>
<p>def withCodeBlock:
<br>print('test')</p>
It strips out the <code> tags, how can I stop this?

I found my issue, my sanitizer was removing a wrapping <pre> tag around the codeblock
editor.setData("<p>test comment</p><pre><code class=\"python-code\">def withCodeBlock:<br /> print('test')</code></pre>");
works perfect

Related

VueJS3 dynamic asset

I load some images like this in my template:
<img
v-if="idRobot === 7"
src="~#/assets/img/faceTibot.png" />
But I'd like to load the asset dynamically. For example, something like this would be great:
<img
v-if="idRobot === 7"
:src="`~#/assets/img/${dynamicasset}.png`" />
Actually, when I do this, VueJS thinks I want to load the string "~#/assets/img/${dynamicasset}.png".
Is what I want even possible in VueJS3?
Ah, BTW I searched SO and found this but suggested require solutions don't work: https://stackoverflow.com/a/47480286/1098303
Thanks in advance
Have you tried this solution ?
<img :src="require(`~#/assets/img/${dynamicasset}.png`)" />

#HtmlRaw One Word

im trying to use razor to generate a url like this
<img id="currentPic" src="/content/img/#Html.Raw(Model.user.defaultImage).png" />
but the .png bit is being added to the #htmlraw syntax and is not compiling. I know i need to tell the page that #htmlraw is over. I tried using ; which worked - but the ; was also displayed in the string when displayed.
How can i get it so it would display like this. When Model.user.defaultImage = random1
<img id="currentPic" src="/content/img/random1.png" />
thanks
try adding a new set of parenthesis
<img id="currentPic" src="/content/img/#(Html.Raw(Model.user.defaultImage)).png" />
Try #{Html.Raw(Model.user.defaultImage)}
I think you don't need Html.Raw, just use
<img id="currentPic" src="/content/img/#(Model.user.defaultImage).png" />
This feels like a hack, but works:
<img id="currentPic" src="/content/img/#Html.Raw(Model.user.defaultImage + ".png")" />

Using ng-repeat variable inside src attribute in angularjs?

I have the following:
div.container
script(src='/js/bootstrap/holder.js')
p.text-info(ng-pluralize,
count="devices.length",
when="{ '0': 'There are no fragments.', 'one': 'There is 1 fragment.', 'other': 'There are {} fragments.'}")
ul.unstyled(ng-repeat='fragment in devices')
ul.thumbnails
li.span
div.thumbnail
img(src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}")
div.caption
h3 {{fragment.name}}
p {{fragment.dimension}}
ul.unstyled(ng-repeat='component in fragment.components')
li {{ component.name }}
The problem is in src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}", i.e. even if looking at the resulting html I see a correct src (src="holder.js/300x200") it does not show the image. My guess is this is not how one uses angular variables inside attributes..
How can I make it work?
EDIT:
it seems it does not execute holder.js..
here is the source: in the first call I used angular {{hash}} in the second I manually put holder.js/300x200
<div class="thumbnail">
<img src="holder.js/1678x638">
<img src="data:image/png;base64,iVBORw0KG...ElFTkSuQmCC" data-src="holder.js/300x200" alt="300x200" style="width: 300px; height: 200px;">
</div>
The documentation explains that quite clearly:
Using Angular markup like {{hash}} in a src attribute doesn't work right: The browser will fetch from the URL with the literal text {{hash}} until Angular replaces the expression inside {{hash}}. The ngSrc directive solves this problem.
So you must use:
<img ng-src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}" />

ModX Eform: Captcha not generating image

I am trying to get CAPTCHA working on the eForm plugin. I have added the input form field:
<label for="cfCaptcha">Captcha:<br />
<img src="[+verimageurl+]" alt="verification code"><br />
<input id="vericode" name="vericode" class="text" type="text">
and I have added
&vericode=`1`
to the eForm call.
and have added the Template Variable [+verimageurl+] to my template.
However, when I preview the form all I see in the image area is <img src="" alt="verification code">
Would anyone know what I am doing wrong?
Did you get this fixed?
Check that you ended the label code. Run it through w3c code checker too.
A few times I have left a element un-closed and it breaks the whole thing.

How to get the total number of pages in RML template?

There is a tag in RML, <pageNumber>, that displays the the current page number.
But how can I get the total number of pages of the generated PDF document?
I would like to add a pagination with something like "Page 1/2", "Page 2/2":
Page <pageNumber /> / <pageCount>
But the <pageCount> tag doesn't exist.
After spending a considerable amount of time, I found this:
At the end of the <story>, add:
<namedString id="lastPage"><pageNumber/></namedString>
To display pagination, use:
Page <pageNumber /> / <getName id="lastPage" default="0" />
I´ve been working in a solution for this case in OpenErp:
<document>
<template>
<pageTemplate>
<stylesheet>
...
<paraStyle name="main_footer" fontSize="7.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
...
</stylesheet>
...
...
<!-- Page Footer -->
<place x="1.5cm" y="0cm" height="1cm" width="19.0cm">
<para style="main_footer">[[ o.name or '']] | Página: <pageNumber/> de </para>
</place>
<drawString x="4.9cm" y="0.74cm"><pageCount/></drawString>
...
Basically, it "draws" the <pageCount> tag at the left of my footer text. The solution from #alartur is more elegant but it does´t work in the OpenErp rmltopdf converter.
We must use Helvetica font at 7px for our footer text because is the default font used in the rmltopdf code for <pageCount>