fix(image): keep data: URI images on markdown round-trip - #9159
Open
guillaume-flambard wants to merge 1 commit into
Open
fix(image): keep data: URI images on markdown round-trip#9159guillaume-flambard wants to merge 1 commit into
guillaume-flambard wants to merge 1 commit into
Conversation
guillaume-flambard
requested review from
max-nextcloud,
mejo- and
silverkszlo
as code owners
September 2, 2026 09:38
Markdown files can legitimately contain base64 images. Both image parse rules excluded img[src^=data:] because the TipTap allowBase64 option defaults to false, so those images never made it into the document and were silently dropped from the file on the next save (nextcloud#9108). Enable allowBase64 on the Image and ImageInline extensions: the file content is the user's own, and the editor is expected to preserve it, not to filter it. Regression test covers both the block (figure) and the inline image path. Signed-off-by: Guillaume Flambard <g.flambard@gmail.com>
guillaume-flambard
force-pushed
the
fix/data-uri-images-9108
branch
from
September 2, 2026 12:37
1c5f849 to
51a4828
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9108.
Editing a markdown file that contains base64 images (data: URI) deleted those images from the file on the next save. The root cause sits in the image parse rules: both the block
ImageandImageInlineextensions excludeimg[src^=data:]when the TipTapallowBase64option is false, and nothing in this app turns it on. markdown-it parses the data: URI fine, but the img never becomes a document node, so the save writes the file without it. That exclusion is the upstream TipTap default, not a decision this app ever made, and there is nothing in the git history suggesting it was deliberate here.The change enables
allowBase64on both extensions. The file content is the user's own and the editor's job is to preserve it, not to filter it. Rendering already goes through theImageViewnode view, which handles the src as-is.Regression test added in
markdown.spec.js, covering both paths:Both round-trip through the editor byte-identical. Full unit suite: 1582/1582 across 50 files. Before the change the new test fails (the image is dropped), which is the reported data loss.