johan
December 30, 2020, 10:28am
#1
Hi,
I’m trying to preview some text:
{{ content.text }}
The output of this will be:
Lorem ipsum dolor sit amet: - My - List - Items
Instead of:
Lorem ipsum dolor sit amet:
- My
- List
- Items
The field “text” is a textarea.
If I do something like below the output is right, but I don’t want this to be editable inline. I just want to preview the textarea. Just as using the ->kirbytext()
for templates.
<k-input
:buttons="false"
:value="content.text"
type="textarea"
@input="update({ text: $event })"
/>
texnixe
December 30, 2020, 11:36am
#2
i think your PHP needs to return the computed text property.
till_k
June 23, 2021, 7:59am
#3
I’m having the exact same problem and don’t really understand what this means. How can I define what the PHP returns when calling the field from the Vue component?
till_k
June 23, 2021, 8:09am
#4
I also tried something like
<div v-html="content.text" />
but it (unsurprisingly) also does not render HTML.
You need a custom API route that returns the rendered HTML, because the field value itself is just markdown.
h2o
May 3, 2022, 1:29pm
#6
Is this solved? How is it done?
till_k
May 16, 2022, 1:56pm
#7
I for my part gave up and worked around it. So unfortunately I never solved it.
As has already been mentioned, this needs a custom route, see also:
Hello,
I’m trying to make a custom preview. Is there any way to layout markdown text in the preview ?
/site/plugins/custom-block/index.js in wich {{ content.contenu }} is a text written in markdown :
panel.plugin("lineaire/element-block", {
blocks: {
element: `
<div class="element__content" @click='open'>
{{ content.contenu }}
</div>
`
}
});
Or use the writer field for your blocks.