mirror of
https://github.com/ankitects/anki.git
synced 2026-10-02 05:24:38 +08:00
2fae55543cfaa82880b84787b09b0ebf06ac9e29
## Linked issue (required) Fixes #5567 ## Summary / motivation (required) Pasting a base64 image in the new editor currently corrupts its bytes, and the HTML paste path can put image markup into an image's `src`. Decode base64 directly into bytes and return the saved filename from the inline-image helper. Read the clipboard PNG preference's boolean value so a disabled preference selects JPEG. Add regressions through the public clipboard APIs for plain-text and HTML data URLs and both image-format settings. Include editor route sources and tests in the Vitest build inputs so edits to these regressions reliably rerun the tests. ## Steps to reproduce (required, use N/A if not applicable) Using a disposable profile on the base revision: 1. Open the new editor and disable "Paste without shift key strips formatting" to enable extended paste. 2. Paste the base64 PNG data URL from the linked issue as plain text, then as the source of an image in clipboard HTML. Inspect the stored media bytes and inserted image source: the bytes change and the HTML source is invalid. 3. Disable "Paste clipboard images as PNG" and paste a bitmap image through the clipboard path. PNG is still selected. 4. After a successful `just test-ts`, edit only an editor route test and rerun it. The build incorrectly reuses the prior Vitest result. ## How to test - [x] `RELEASE=1 just check` passed on this focused upstream-based branch (`ee16fc015`), using Apple Silicon macOS and the repository's pinned toolchains. - [x] Added or updated regression coverage for the changed behavior. Clipboard regressions check exact decoded bytes, a local media filename in the inserted image, and both PNG/JPEG preference values. Confirmed route test edits invalidate the Vitest target. Clipboard/backend APIs are mocked; no user collection is accessed. ## Risk / compatibility / migration (optional) No database migration or new dependency. The legacy paste branch is unchanged. The build input change only causes relevant source/test edits to rerun Vitest. Complete local validation was on macOS; other platforms depend on CI. ## UI evidence (required for visual changes; otherwise N/A) N/A: no visual design changes. Regression tests inspect the inserted image markup. ## Scope - [x] This PR is focused on one change (no unrelated edits). --------- Co-authored-by: Abdo <abdo@abdnh.net>
…
…
…
…
…
…
…
…
…
…
…
Anki
This repo contains the source code for the computer version of Anki.
About
Anki is a spaced repetition program. Please see the website to learn more.
Getting Started
Contributing
Want to contribute to Anki? Check out the Contribution Guidelines.
For more information on building and developing, please see Development.
Contributors
The following people have contributed to Anki: CONTRIBUTORS
Anki Betas
If you'd like to try development builds of Anki but don't feel comfortable building the code, please see Anki betas.
License
Anki's license: LICENSE
Languages
Rust
37.5%
Python
22.9%
MDX
19.5%
TypeScript
9.5%
Svelte
8.9%
Other
1.3%