Skip to content

feat(browser): accept standalone SVG text through Ctrl-drag - #813

Merged
KnifeLemon merged 3 commits into
KnifeLemon:mainfrom
1644ye:codex/upstream-svg-selection
Oct 30, 2026
Merged

KnifeLemon merged 3 commits into
KnifeLemon:mainfrom
1644ye:codex/upstream-svg-selection

Conversation

@1644ye

@1644ye 1644ye commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Accept a selected, standalone, well-formed <svg …>…</svg> through the existing Ctrl-drag path. Surrounding whitespace is allowed. Ordinary text, text links, mixed HTML, sibling SVG roots, escaped markup and malformed XML retain their existing behavior. There is no new setting or browser extension in this PR.

Selections are normalized to an SVG namespace when necessary. External image/font/stylesheet references are reported as a failed result with an actionable message; they are not silently rendered as a blank image. Embedded data resources and local fragment references remain supported.

Tests cover accepted/rejected/almost-well-formed XML, external dependencies, and Avalonia drag-enter/drop events through both PNG (pixel assertion) and PDF (drawn-path assertion). The missing-resource cases also exercise both targets and check that no output file remains.

Closes #820.

Validation on Windows / .NET 10, based on upstream 7fc129f:

  • dotnet format Filee.slnx --no-restore --verify-no-changes: passed.
  • All six dotnet test projects passed: App 1,638; CLI 55; Core 773; Engines 1,942; Platform 94; Setup 206 (4,708 passed, zero failures in the final project runs).
  • Final-head browser-drop recheck: 18 passed, zero skipped, including SVG to PNG/PDF and missing-resource errors.
  • Conditional tests remain skipped for unavailable optional engines, non-Windows features, Explorer packaging artifacts and symlink permissions; the media-generation test is explicitly disabled upstream. These are not represented as passed tests.

Test environment notes: App/engine tests used an isolated FILEE_DATA_DIR so installed optional engines did not invalidate the upstream engine-install tests. Setup tests require the real default paths and were rerun without that override (206/206). One existing StallWatch timing assertion failed during the initial parallel workload; a complete Engines rerun passed (1,942 passed, 210 skipped). No engine, installer or timeout-test code was changed for these environment issues.

@github-actions github-actions Bot added the feature New features label Oct 30, 2026
@KnifeLemon

Copy link
Copy Markdown
Owner

Thanks, @1644ye! Before reviewing the code, a question about scope.

Converting SVG markup selected as text (from a page or an editor) is a fairly niche case, and the PR adds a new setting for it (on by default) plus a parser for mixed and escaped fragments. Please open an issue describing:

  • the situation you're solving (where the SVG text comes from);
  • what happens today.

Then we can agree on whether it belongs in Filee and how before you spend more time here. New features start with an issue so the design is settled first. I'll keep this draft open in the meantime.

@1644ye

1644ye commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the scope feedback. I opened #820 with the concrete workflow, existing behavior, and the smaller integration options for discussion. This PR will remain draft while we agree on the requirement and scope.

@1644ye 1644ye changed the title feat(browser): accept selected SVG markup in Ctrl-drag conversions feat(browser): accept standalone SVG text through Ctrl-drag Oct 30, 2026
@1644ye

1644ye commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Reworked to the agreed scope in a63aa10.

Only a single, well-formed standalone SVG text selection is added to Ctrl-drag. The setting, HTML extraction, escaped-markup handling and broad renderer changes are removed. Unresolved external resources become an actionable failed result. Parser tests and real drag-enter/drop tests through PNG/PDF are included.

dotnet format --verify-no-changes passed. All six test projects now pass (4,708 passed across the final project runs); the final-head browser-drop recheck passed all 18 cases. The PR description records conditional skips and the installer-path/timing test reruns rather than hiding them.

Marking ready for your CI approval. This PR contains no extension changes.

@1644ye
1644ye marked this pull request as ready for review October 30, 2026 12:55
@1644ye
1644ye requested a review from KnifeLemon as a code owner October 30, 2026 12:55

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @1644ye, this matches the scope we agreed in #820:

  • Only a single, well-formed <svg> selection is accepted. InlineSvg.Read checks the prefix first, parses with DTDs prohibited and no resolver, caps the size, and rejects anything else in the document. Ordinary text still doesn't wake the donut (MayOffer).
  • A missing xmlns (common in HTML selections) gets the SVG namespace, so converters read it.
  • Unresolved href, CSS url() and @import become a failed result with an explanation instead of a blank picture, and data: and #fragment references pass.
  • The tests cover accepted, rejected and almost-well-formed SVG, and drops through to PNG and PDF.

One thing to keep in mind, not blocking: MayOffer runs on every drag-over, and for an SVG selection it parses the whole text each time. That's fine at today's 4 MB cap; if it ever shows up in profiles, caching the last text and result would remove it.

The Windows ARM64 job was cancelled (not a test failure), so I've rerun it. I'll merge once it's green.

@KnifeLemon
KnifeLemon merged commit 26cc434 into KnifeLemon:main Oct 30, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Discuss converting selected SVG markup with the existing drag gesture

2 participants