Commit Graph

9926 Commits

Author SHA1 Message Date
Damien Elmes
c923553a53 Replace newlines with linebreaks when importing without HTML
https://forums.ankiweb.net/t/line-breaks-are-removed-when-importing-csv-on-linux/26451
2023-01-18 21:00:33 +10:00
Damien Elmes
0be9ee8dcc Fix ctrl+enter not working when importing screen first opened
Thanks to blueputty01 for investigating!

Closes #2326
2023-01-18 15:41:47 +10:00
Damien Elmes
cf45cbf429
Rework syncing code, and replace local sync server (#2329)
This PR replaces the existing Python-driven sync server with a new one in Rust.
The new server supports both collection and media syncing, and is compatible
with both the new protocol mentioned below, and older clients. A setting has
been added to the preferences screen to point Anki to a local server, and a
similar setting is likely to come to AnkiMobile soon.

Documentation is available here: <https://docs.ankiweb.net/sync-server.html>

In addition to the new server and refactoring, this PR also makes changes to the
sync protocol. The existing sync protocol places payloads and metadata inside a
multipart POST body, which causes a few headaches:

- Legacy clients build the request in a non-deterministic order, meaning the
entire request needs to be scanned to extract the metadata.
- Reqwest's multipart API directly writes the multipart body, without exposing
the resulting stream to us, making it harder to track the progress of the
transfer. We've been relying on a patched version of reqwest for timeouts,
which is a pain to keep up to date.

To address these issues, the metadata is now sent in a HTTP header, with the
data payload sent directly in the body. Instead of the slower gzip, we now
use zstd. The old timeout handling code has been replaced with a new implementation
that wraps the request and response body streams to track progress, allowing us
to drop the git dependencies for reqwest, hyper-timeout and tokio-io-timeout.

The main other change to the protocol is that one-way syncs no longer need to
downgrade the collection to schema 11 prior to sending.
2023-01-18 12:43:46 +10:00
RumovZ
1be30573e1
Replace dissimilar crate with difflib (#2322)
This also inserts the expected text if it's missing at the very
beginning of the provided text.
2023-01-16 09:49:34 +10:00
Hikaru Y
604e0f46e1
Fix and refactor image size constraints (#2318)
* Remove 'ResizableImage.svelte'

Rather than having a svelte file that just sets global styles, it's
better to set those in a (s)css file.

* Fix and refactor image size constraints

- Fixes https://forums.ankiweb.net/t/2-1-56-image-size-problem-in-editor/26207
- Use :host-context() to switch image styles instead of toggling CSS
variables.

* Fix toolbar buttons for image overlay sometimes being cut off
2023-01-13 23:18:25 +10:00
Damien Elmes
8131ea1908 Fix quotes breaking field descriptions, and prevent content injection
https://forums.ankiweb.net/t/some-field-descriptions-are-not-showing/26295
2023-01-13 16:37:49 +10:00
Matthias Metelka
df456e959d
Make QCheckBox more visible (#2314) 2023-01-12 09:16:38 +10:00
Damien Elmes
10fd465edb Increase delay for mutter
It's a nasty hack, and would be nice if we could easily limit it to
users who are using Mutter.
2023-01-11 19:59:34 +10:00
dependabot[bot]
b5cca03d09
Bump bzip2 from 0.4.3 to 0.4.4 (#2310)
Bumps [bzip2](https://github.com/alexcrichton/bzip2-rs) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/alexcrichton/bzip2-rs/releases)
- [Commits](https://github.com/alexcrichton/bzip2-rs/commits/0.4.4)

---
updated-dependencies:
- dependency-name: bzip2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-11 12:58:35 +10:00
Matthias Metelka
ba822d9ee9
Simplify padding definition and center text (#2308) 2023-01-11 12:58:02 +10:00
Damien Elmes
5db95c97e3 Fix incorrect added total/average
https://forums.ankiweb.net/t/anki-2-1-56-release-candidate/26001/18
2023-01-10 09:45:54 +10:00
Hikaru Y
25def4f741
Fix spaces not handled properly when entering text around MathJax (#2307)
Regressed in #2288
https://forums.ankiweb.net/t/2-1-56-qt6-pressing-space-after-mathjax-inserts-nbsp-with-escaped/26147
2023-01-10 08:51:09 +10:00
RumovZ
6df7be90c5
Fix negated introduced:x search (#2306)
1. Add outer brackets.
2. Coalesce aggregate, because `null and true` is `null` in SQL land,
so cards that were not introduced, but manually rescheduled in the
period of interest, would not show up in a negated search.
2023-01-10 08:49:35 +10:00
Aristotelis
91d563278f
Fix toolbar add-on breakages and introduce toolbar tray layout & API (#2301)
* Layout toolbar using CSS grid, introducing left and right trays

The trays provide a space for add-ons to introduce their own widgets to the toolbar without interfering with each other.

* Align tray items to the top

* Move absolutely positioned add-on items to right toolbar tray

Workaround that fixes breakages in add-ons like AMBOSS, Study Timer, and potentially others that currently still inject absolutely positioned elements into the toolbar using `top_toolbar_did_init_links`.

* Account for add-ons that add manual padding (e.g. Study Timer)

* Add docstrings and slightly refactor

* Tweak item alignment

* Introduce hooks for extending left and right toolbar trays

* Assign CSS classes to all tray items

* Add disclaimer on transitional nature of new hooks
2023-01-10 08:48:50 +10:00
Damien Elmes
cef672a6a1 Update Windows/Linux to Qt 6.4.2
Closes #2275
2023-01-09 16:22:47 +10:00
Matthias Metelka
9f8667fb47
Auto-hide toolbar in Reviewer (#2262)
* Give webviews a slide-in animation

if reduced motion isn't set.

* Auto-hide toolbar in review mode

moving the mouse above the main webview expands the toolbar. When the mouse leaves the toolbar, it will collapse after a delay of 2s.

* Save some space on bottom toolbars

* Use props for all hard-coded transition durations

and decrease most commonly used duration (200ms) to 150ms.

* Move auto-hide logic into ToolbarWebView

and handle auto-hide specific events in the respective webview subclasses.

* Fix typing issues

* Fix flickering issue

* Add auto_hide_toolbar opt-in to preferences

* Rename hide_toolbar to collapse_toolbar

to better describe the dock-like behaviour.

* Rename setting to minimize_distractions

* Reduce calls to pm in eventFilter

* Run formatter

* Revert setting title to something more specific

* Increase default animation time to 180ms

* Inset toolbar in review mode

when auto-hide is not enabled.

* Use card background on toolbar and add glass effect

* Use flatten/elevate over inset/outset

* Use flatten/elevate over inset/outset

* Update toolbar.py

* Fix toolbar background delay

* Tweak styles

* Use "collapse" instead of "auto-hide"

* Fix background misalignment in collapse mode

* Do not collapse toolbar when pointer is outside MainWebView

* Reduce hide_timer interval to 1000ms

* Use CSS to hide toolbar instead of setting webview height

* Add guard to prevent backdrop-filter: blur on Qt 5.14

* Apply transition to body instead of toolbar

to not complicate things for #2301.

* Fix Qt 5.14 and apply guard globally

* Fix background image scaling difference

* Tweak preference wording (dae)
2023-01-09 14:39:31 +10:00
Damien Elmes
afca2f52ce Update translations 2023-01-09 11:09:02 +10:00
Damien Elmes
3b0fd7b3eb Bump version 2023-01-09 11:08:53 +10:00
Damien Elmes
07fd88ddea Allow timestamps to be a day ahead
https://github.com/ankitects/anki/issues/1895#issuecomment-1374574230
2023-01-09 10:04:48 +10:00
dependabot[bot]
4e92c29815
Bump tokio from 1.23.0 to 1.23.1 (#2303)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.23.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.23.0...tokio-1.23.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-07 10:01:56 +10:00
Damien Elmes
7f71277514 Whitelist dependabot 2023-01-07 09:53:29 +10:00
Damien Elmes
309c467403 Work around button margins being too thin on Windows 2023-01-05 17:15:10 +10:00
Damien Elmes
f9aa232d9b Fix cloze buttons not working in MathJax editor
Regressed in #2144
2023-01-05 15:58:32 +10:00
Damien Elmes
037610715d Fix incorrect count in 'added' tooltip 2023-01-05 10:21:26 +10:00
Damien Elmes
8206f39bdc Fix sparse today stats
Not safe to assume revlog is ordered by query
2023-01-05 10:14:37 +10:00
Damien Elmes
bc6975973e Display a more helpful error when the locale is wrong 2023-01-04 19:01:55 +10:00
Damien Elmes
f2bb0395bf Fix unreadable text when searching in sidebar
We used to have a separate SUSPENDED_BG, but it got removed in the UI
refactor.

https://www.reddit.com/r/Anki/comments/1029gbw/is_anyone_else_with_2155_experience_way_to_bright/
2023-01-04 18:16:19 +10:00
Damien Elmes
0eddb25287
Integrate AnkiDroid's backend patches into the repo (#2290)
* Relax chrono specification for AnkiDroid

https://github.com/ankidroid/Anki-Android-Backend/pull/251

* Add AnkiDroid service and AnkiDroid customizations

Most of the work here was done by David in the Backend repo; integrating
it into this repo for ease of future maintenance.

Based on 5d9f262f4c
with some tweaks:

- Protobuf imports have been fixed to match the recent refactor
- FatalError has been renamed to AnkidroidPanicError
- Tweaks to the desktop code to deal with the extra arg to open_collection,
and exclude AnkiDroid service methods from our Python code.

* Refactor AnkiDroid's DB code to avoid uses of unsafe
2023-01-03 13:11:23 +10:00
Damien Elmes
922574444f Update json5 due to CWE
Doesn't affect us, but satisfies Dependabot
https://cwe.mitre.org/data/definitions/1321.html
2023-01-03 13:03:25 +10:00
Damien Elmes
65a79c743f Update translations 2023-01-03 12:59:50 +10:00
Damien Elmes
30bf5f8b39 Fix 'git submodule' after git security update 2023-01-03 12:59:50 +10:00
kelciour
e9428449ff
Fix two mpv issues on Windows (#2294)
* Fix mpv with two Windows accounts at the same time

Closes #2203

* Add a workaround for audio cut off early on Windows

Closes #1730
2023-01-03 11:59:39 +10:00
Aristotelis
2270ff425a
Add dev tools for live-reloading Anki's web views (#2151)
* Add dev tools for live-reloading the web stack while running Anki

* Handle CDP connection errors more graciously

* Include sass in web stack watchers

* Refactor monitored folder and event definition

* Switch to more specific build target

Thanks to @hikaru-y

* Add PyChromeDevTools to dev requirements

* Update rebuild-web for ninja

* Satisfy mypy

* Remove ts-watch

Superseded by web-watch (the version here was also still based around bazel)

* Simplify calls to other build tools

Given that `./ninja qt/aqt` has to be run from the project root anyways, it doesn't make sense to use calls relative to `rebuild-web` in an ill-guided effort to lower dependencies on hard-coded paths.

* Remove remaining script-relative tool path
2023-01-03 11:55:58 +10:00
Damien Elmes
3357389309 Fix some regressions with the graphs when printing
- page-break avoidance needs to be moved to the wrapping TitledContainer
- grid has to be disabled, as it prevents page breaks from working, and
shows too many columns (https://forums.ankiweb.net/t/stats-save-as-pdf-problems-2-1-55/25773)
- content underflowed the top header
2022-12-30 17:37:38 +10:00
Damien Elmes
ba68764fcb Another attempt at fixing missing cacert.pem
A few reports like https://forums.ankiweb.net/t/error-report-check-database-did-not-work/25796
indicate that the previous solution has not helped, and has just made things
worse. My guess is that AppNap on macOS is preventing the timer from even
running before the file gets cleaned up.
2022-12-30 15:30:53 +10:00
Damien Elmes
766e28d64d Clean up build artifacts between runs 2022-12-30 15:22:11 +10:00
Hikaru Y
be6d1dfb66
Work around issue with entering text around MathJax via IME (#2288)
* Add 'placement' property

* Extract logic for moving text node into instance method

... so that it can be used elsewhere.

* Add writable store to indicate whether composition session is active

* Work around issue with entering text around MathJax via IME

* Make get() called only once while composition session is active
2022-12-30 13:32:41 +10:00
Ren Tatsumoto
7d22053730
Mention how to fix build crash in the readme. (#2286)
* update linux.md

mention how to fix libcrypt.so.1-related build crash

* Mention Fedora as well (dae)
2022-12-30 13:10:37 +10:00
Damien Elmes
4c5a2461d0 Handle broken utimes() on Android
Closes https://github.com/ankidroid/Anki-Android/issues/12827
Closes https://github.com/ankidroid/Anki-Android/issues/12974
2022-12-28 16:33:06 +10:00
Damien Elmes
272d53079f Pad buttons instead of using min-width
Qt seems to be treating min-width more like width, and truncates text.
The issue is not limited to macOS with force_custom_styles: with a
sufficiently large amount of text on a button, it truncates on other
platforms too.

https://forums.ankiweb.net/t/2-1-55-issue-with-auto-browser-and-upload-download-dialog/25636

There are a few other uses of min-width in the styling - it may be worth
checking whether they suffer from the same issue as well.
2022-12-28 12:04:44 +10:00
Damien Elmes
b415c7a9a5 Formatting tweak
Triggered by './ninja format', though curiously it did not get picked
up in a check.
2022-12-28 11:53:21 +10:00
Damien Elmes
cfe1b79737 Fix images not being constrained to field width
Appears to have regressed in #2071. I'd used 'inherit' so that the default
editable styling would impose a 100% limit, but it appears that variable
interpolation prevents the parent styling from being applied.
2022-12-24 12:57:38 +10:00
Damien Elmes
ff1f5f9f7a Fix lack of marked color in day mode
The call to .lighter() was turning the already-light color into white.

https://forums.ankiweb.net/t/2-1-55-marked-cards-not-colored-in-browser/25568
2022-12-24 11:38:46 +10:00
Damien Elmes
1dc728eb6c Fix incorrect macOS minimum limit in alternate build 2022-12-24 11:09:53 +10:00
Damien Elmes
8a9535383c Fix dark mode display issues on macOS/Qt5 2022-12-24 11:02:59 +10:00
Damien Elmes
a38121a713 Add Debug impl for Collection 2022-12-24 10:44:41 +10:00
Damien Elmes
a82f8d6872 Remove unused before_upload method 2022-12-24 10:44:41 +10:00
Damien Elmes
0570cfdf48 Migrate from slog to tracing
The Rust community appear to have converged on tracing - it's used by
the Rust compiler, and receives close to 10x the number of downloads
that slog does. Its API is more ergonomic, and it does a much nicer
job with async rust.

To make this change, we no longer pass around explicit loggers, and rely
on a globally-registered one. The log file location has been changed
from one in each profile folder to a single one in the base folder. This
will remain empty for most users, since only errors are logged by default,
but may be useful for debugging future changes.
2022-12-24 10:44:40 +10:00
Damien Elmes
687647af24 Update openssl
.44 was yanked
2022-12-23 16:03:43 +10:00
Damien Elmes
e33bed2a25 Fix incorrect packaging of fcitx libs
Transform was being applied to ./symlinks

Closes #2278
2022-12-21 19:31:13 +10:00