Repository navigation
feat: image and video blocks - #3638
global-prog wants to merge 8 commits into
Conversation
b719715 to
e52688b
Compare
|
@global-prog Please look at the corresponding issue at #624 to see if you covered all of what has been discussed there already. Also please add the AI declaration to your description if you used AI for this. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thanks, I read through #624. It is mostly about section headings and descriptions to break up a long form, which this PR does not do: it only adds image and video blocks. So I don't think it should close #624 on its own. Section headings are what #2913 is working on. One thing that may help there: this PR adds a shared If you decide display content shouldn't be a question type, which is the open question on #2913, I'll follow that decision here too. The AI declaration is added to the description. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
Hey @global-prog! Thank you for work on it. Few notes from my side:
|
|
BTW why can't we just embedd images/video into question description (as it already supports markdown)? |
f381500 to
5e8ec20
Compare
Because of CORS / same origin. Markdown in the sense of Collectives, just stores the images next to the markdown in Nextcloud files. So a simple start is what this PR does, relying on public shares and than you are fine, or even internal shares that just work for the people who it has been shared with. Tables has the same concept now. You can add images in a column, but only people with read permissions can see it. Not optimal, but a start |
c727a38 to
cfb2c14
Compare
edd7780 to
b034503
Compare
b034503 to
a76e724
Compare
Adds two display-only blocks so a form can show a picture or point at a video between its questions, rather than only text. They are modelled as ordinary question types that happen to carry no answer, which keeps them in the existing ordering and drag-and-drop with no new concepts. A shared ANSWER_TYPES_DISPLAY_ONLY list marks them so they are skipped when validating a submission and filtered out of exports - without that, each block would add an empty column to every CSV. Video is deliberately NOT embedded in an iframe. Embedding makes every respondent's browser contact the video host on page load, disclosing their IP address and usually setting cookies, which would quietly undermine a form marked as anonymous. It renders as a link the respondent chooses to follow. Images do render inline, since that is the point of an image block, but with referrerpolicy="no-referrer" so the form's address is not passed on, and the editor warns when the address is not on this instance. No schema change: the address and description live in the existing extraSettings. FormsQuestionType is left alone, matching how linearscale, ranking and color are already handled, so openapi.json is unaffected. Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
A display-only block was skipped during validation whether or not an answer came with it, so a hand-made request could store an answer against a block that has nowhere to show it. An absent answer is still expected -- and still must not count as a missing required one -- but a present answer is now refused. The submit view never sends one for these blocks, since they emit no value, so this changes nothing for a form filled in normally. Adds tests for both halves, and for the image and video settings accepted by areExtraSettingsValid, which were not exercised before. Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
A video block was only a link. For YouTube and Vimeo addresses it now shows a placeholder that names the provider and explains that playing the video discloses the viewer's IP address and may set cookies. The player loads only after the viewer clicks "Play video", from youtube-nocookie.com or with Vimeo's do-not-track flag. The link stays below it, and other addresses keep the plain link. The pages showing a form allow these two player origins as frames. Images on another site never loaded, because the content security policy only allows images from the instance. The editor now says that only images stored on this Nextcloud can be shown, and neither view renders a broken image any more. The warning about external addresses is gone, as nothing is loaded from them. The block's fields now line up with the title field in the editor, and the image and link align to the start like the other question content. The link is underlined so it reads as a link. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The submit view validates every question component before sending and stops when one has no validate function, so a form containing an image or video block showed "Some answers are not valid" and could not be submitted. Display-only blocks take no answer and are always valid. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
End-to-end tests check that an image on this instance is shown, that an image on another site is flagged in the editor and not rendered, that YouTube and Vimeo players only load after the respondent clicks "Play video", that other video addresses stay a plain link, and that a form with both blocks can be submitted. A unit test checks that the blocks are left out of the export. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The link of a public share opens the share page, not the file, so an image block given that link showed nothing. Such links are now turned into the share's download address when the block is shown; the stored address stays as entered. A video block whose address is on this instance now plays in a native video player. Nothing leaves the instance, so it needs no consent; it only preloads the metadata, so opening the form does not download the video. If the file cannot be played, only the link is shown. The address field of both blocks now explains which addresses work, and the error for an image on another site says that only images shared publicly from this Nextcloud can be shown. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
NcTextField now types its value as string or number, so the update handlers take both and store the value as a string. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Like sections in other form tools, a block that only shows something can still decide where the form continues, so image and video blocks offer the same "go to after this question" jump as text questions. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
a76e724 to
71140b7
Compare

Summary
Adds two display-only blocks, Image and Video, so a form can show a picture or a video between its questions instead of only text.
They are ordinary question types that carry no answer, so they reuse the existing ordering, drag and drop and jumps ("After question N") without new concepts. A shared
ANSWER_TYPES_DISPLAY_ONLYlist marks them: submission validation refuses an answer to them and exports leave them out, so they add no empty CSV column.What a block can show
The address field explains this in its hint, and every block can carry a description for screen readers (images) or a link text (videos).
Privacy
Embedding a player directly would make every respondent's browser contact the video host on page load, disclosing their IP address and usually setting cookies — on an anonymous form that quietly breaks the promise made to respondents. So the player loads only after consent, from
youtube-nocookie.comor with Vimeo's do-not-track flag. The pages showing a form (app, public link, embed) allow just these two player origins as frames; nothing changes elsewhere on the server.Scope
extraSettings.openapi.jsonis unaffected;FormsQuestionTypeis left alone, as forlinearscale,rankingandcolor.🖼️ Screenshots
Desktop
Mobile, 320 px wide (reflow per WCAG 1.4.10 / BITV 2.0; no horizontal scrolling)
How to test
Automated tests
SubmissionServiceTest: validation refuses answers to the blocks, exports skip them.FormsServiceTest: theirextraSettings, including the jump, are accepted.PageControllerTest: every page showing a form allows the two player origins as frames.tests/fixtures/jump-paths.json: jumps on image and video blocks, checked on the server and in the browser.playwright/e2e/media-blocks.spec.ts: shared images and videos shown inline; external image flagged and not rendered; hints announced with the address field; non-video file falls back to the link; YouTube (watch?v=,youtu.be, shorts) and Vimeo load only after consent with no request before; other video addresses stay a link; consent notice fits at 320 px; a jump on a block skips the question in between; a form with both blocks can be submitted.🤖 AI (if applicable)