nextcloud / forms

đź“ť Simple form & survey app for Nextcloud
https://apps.nextcloud.com/apps/forms
GNU Affero General Public License v3.0
311 stars 96 forks source link

Allow formatting with Markdown #489

Closed EricKerby closed 1 year ago

EricKerby commented 4 years ago

It would be helpful to allow formatting the text in the description and field names with markdown or HTML. For recent forms I created, I found myself wanted to add emphasis to some text as well as a link or two.

skjnldsv commented 4 years ago

@juliushaertl the dedicated component is not yet available, right? :)

juliushaertl commented 4 years ago

No but work in progress https://github.com/juliushaertl/nextcloud-text/

It already is in kind of a working state except for some node types like images, but needs some more polishing for a first release. Unfortunately I didn't have much time lately.

skjnldsv commented 4 years ago

It's definitely not a priority! Take your time :)

EricKerby commented 4 years ago

Thanks, @juliushaertl ! Providing a visual text editor component which Forms and other apps can then utilize certainly sounds like a solid approach to satisfy this enhancement request.

bernd-wechner commented 3 years ago

We'd love to be able to add links tot he intro as well! But basic layout of the intro would be awesome!

Not sure why it needs a dedicated component. Simply interpreting the text entered as HTML is enough. I don't mind writing the HTML literally. Adding checkbox that requests as much would aid in backward compatibility (not causing old forms to render as HTML when they aren't (hence losing all white space and text layout).

bernd-wechner commented 3 years ago

Not sure why the thumbs down from @skjnldsv because, given formatting is not available I put the description of the form onto a PicoCMS page, no problem, and it just links to the form for completion, but I wanted badly to put in a link back from the form to the intro page as well, measly little link. Turns out it's easy enough to do with a small tweak:

diff --git a/src/views/Submit.vue b/src/views/Submit.vue
index 7fd055b..52981ee 100644
--- a/src/views/Submit.vue
+++ b/src/views/Submit.vue
@@ -30,7 +30,7 @@
                                </h2>
                                <!-- Do not wrap the following line between tags! `white-space:pre-line` respects `\n` but would produce additional empty first line -->
                                <!-- eslint-disable-next-line -->
-                               <p v-if="!loading && !success" class="form-desc">{{ form.description }}</p>
+                               <p v-if="!loading && !success" class="form-desc" v-html="form.description"></p>
                                <!-- Only visible if at least one question is marked as mandatory-->
                                <p v-if="mandatoryUsed && !loading && !success" class="info-mandatory">
                                        * {{ t('forms', 'Required questions') }}

and I'm rolling, my form introduction is rendered as HTML not text and I have my link (and if I wanted, much richer formatting but hey, I'm, content with one link for now - the form will be relevant only until October and if there's a forms update before then I can ignore it or apply it and it clobbers my patch I can reapply it). In the meantime Nextclouds integrity check is awesome and spots that my patched build has been patched and I get the warning on the Overview page - thumbs up for Nextcloud's security there!

In the mean time there is a Nextcloud markdown editor app: https://apps.nextcloud.com/apps/files_markdown

which the PicoCMS app suggests and seems to wok well.; Not fro Forms of course as the description isn't in the file system as a .md file.

P.S. Of course there are always security issues raised when a user can submit HTML code for rendering. I wouldn't even suggest that a simple patch like this is appropriate for a public release. Just saying it was a possible local tweak to get what I needed is all. If you're in the same boat this is the one liner that will get you rolling (well it's a little more than that as you have to clone the app, a fix the line, build and copy the build to your Nextcloud but hey, it's doable, though you might be able to deminify the built file and edit it in situ and reminify it. The file it builds to seems to be: js/forms-submit.js.map)

skjnldsv commented 3 years ago

Of course there are always security issues raised when a user can submit HTML code for rendering

This is the reason of my thumb down. I can tell you already html will not be supported as user input by Nextcloud. :) Sorry!

bernd-wechner commented 3 years ago

Nextcloud does allow some HTML. b tags, a tags both work on the PicoCMS app.

skjnldsv commented 3 years ago

Nextcloud does allow some HTML. b tags, a tags both work on the PicoCMS app.

PicoCMS is not an officially supported nc app. Like said, markdown yes, html, no. relevant https://github.com/nextcloud/viewer/issues/499#issuecomment-679142589

bernd-wechner commented 3 years ago

Not offically supported? By what measure is that?

https://nextcloud.com/blog/nextcloud-introduces-easy-website-builder-for-education-edition-with-picocms/

Fanfare like this doesn't half suggest that Nextcloud are dully into it and 'officially' if you will. Is there some measure of officialness I'm missing? Just curious.

skjnldsv commented 3 years ago

Not offically supported? By what measure is that?

Sorry, I should have said that PicoCMS is not an app we ship, or that I can control. The term 'supported' of course makes no sense without a support contract with us in any case. The author can decide to support some html - but at Nextcloud GmbH we won't as we consider it an unacceptable security risk.

bernd-wechner commented 3 years ago

So the forms app is something Nextcloud GmbH ships?

skjnldsv commented 3 years ago

So the forms app is something Nextcloud GmbH ships?

Nope, but it's a featured app. Capture d’écran_2020-08-31_13-48-28

Let's stop arguing here. This is something that we'll not do. The decision is final.

jdittrich commented 3 years ago

Agree that formatting would be nice, I'm not sure if it needs to be (full) markdown. I guess at least most of my needs would be covered by italic and bold.

loelkes commented 3 years ago

Agree that formatting would be nice, I'm not sure if it needs to be (full) markdown. I guess at least most of my needs would be covered by italic and bold.

I would like to add the possibility of adding links. This is useful for something like "I accept the Terms and Conditions" with a link to the document.

zklmtfr commented 3 years ago

To me personally this is the most important issue of this app. I would like to structure longer descriptions. Is the missing part still in progress or are there other options to handle this? Thanks a lot :)

demlak commented 2 years ago

This issue is open for nearly 2 years now.. it seems, Markdown and/or a WYSIWYG Editor will take more time to come..

In meantime.. how to disable "unformating HTML"? For us, it would be a great workaround to just have HTML correctly rendered as it is.. nextcloud-forms converts HTML to entitys.. but in our case, this is unnecessary. so we would like to disable this conversion. could you give me a hint, where to change the coresponding line in code, that is responsible for rendering/outputting the text/html like this &lt;strong&gt;?

nevermind.. found the solution in hidden comments some lines up: https://github.com/nextcloud/forms/issues/489#issuecomment-683488278 thx

chris2k20 commented 2 years ago

Any news on this, because it would be very useful to have markdown/html support in the description, so we can insert some bold text or even images? :)

torwag commented 1 year ago

I would even go further and propose to have a dedicated editing view which is a markdown file and add to the "standard" markdown, all the form elements as additional markdown syntax including possible configuration options (like mandatory flag, simple input checks, etc.). The presentation view would present the form. This would enable a maximum of flexibility and still allow people to copy/paste snippets of forms from one to another document. You could even keep them in a git repro, or use nextclouds own versioning system.