Rich text: iframe embeds are lost when an entry is saved from the visual editor
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- developer-experience, frontend
Research direction
Start with src/components/ui/editor/html-policy.ts and trace how forbiddenTags, parseMarkdown, and sourceMarkdown handle iframe blocks. Reproduce the reported save flow with a Markdown file containing an iframe, then check whether the saved content preserves it byte for byte without rendering it in the visual editor. The issue names no test files, so locate the relevant editor tests and add coverage for this case.
Written by the indexing model from the issue text.
Description
Problem
The visual rich-text editor removes iframes, and nothing in options.html can allow them. If an entry with an embed (YouTube, Vimeo, Bunny, maps) is opened in the visual editor and saved, the embed is removed from the file. Nothing tells the editor it's been removed.
Many existing sites have embeds in Markdown or HTML content, so this can lose content on otherwise ordinary edits. It worked in 2.x on my fork, where unsupported HTML was kept as a block and written back unchanged.
Steps to reproduce
-
Add a Markdown file with an embed:
Intro text. <iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="Video" allowfullscreen></iframe> More text. -
Open it in a
rich-textfield (default Markdown format). -
Edit "Intro text" in the visual editor and save.
Expected: the iframe is kept.
Actual: the iframe is removed from the saved file.
Cause
In src/components/ui/editor/html-policy.ts:
iframeis inforbiddenTags, so sanitizing the block leaves nothing, andparseMarkdownreturns anomittednode. That node is written back as an empty string.- Wrapping the embed so it's kept as a source block doesn't help:
sourceMarkdownsaves source that contains a forbidden tag as a fenced code block.
Suggestion
Keep forbidden HTML in the document instead of dropping it:
- Treat a block with forbidden tags as a read-only source block. Show it as code, never render it in the editor, and write it back byte for byte.
- Optionally, add an allowlist such as
options.html.embeds: [youtube.com, player.vimeo.com]so the editor can show a sandboxed preview of trusted embeds.
Option 1 alone would prevent the data loss without any risk in the editor, since the HTML is never rendered there.
Workaround
Editing in Source mode keeps the iframe. A shortcode such as {% youtube "id" %} with options.preserve avoids raw HTML altogether.
Version
3.0.1, self-hosted on Cloudflare Workers.
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 564
- Avg merge
- 8m
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hunvreus/pagescms
-
Media browser returns "Not found" for repositories using the SHA-256 object formatPossibly taken @adamchodera claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Hosted 3.0.1: email code sign-in fails for an invited collaborator ("code could not be verified")Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
hunvreus/pagescms#483 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
hunvreus/pagescms#464 · 1 comment ·
Maintainers usually reply within 1 day
All issues in hunvreus/pagescms
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Make the "%" unit spacing the same in the web and in A10Possibly taken @kragent66-glitch claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
nextcloud-libraries/nextcloud-dialogs#2772 ·
Maintainers usually reply within 1 day
-
Editor: leave an uploaded or inserted image's alt text empty, so the preview asks for a descriptionOpen
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 65/100
sveltejs/svelte.dev#2417 ·
Maintainers usually reply within 1 day