Commit Graph

10204 Commits

Author SHA1 Message Date
Abdo
3a32e4b1bd
Disable add-on buttons when no field is focused by default (#2532) 2023-06-05 12:44:28 +10:00
Abdo
51dc5860bd
Fix toggleable editor button styles (#2531) 2023-06-05 12:43:50 +10:00
Damien Elmes
e94ab5a44d Update translations 2023-06-05 09:20:19 +10:00
Damien Elmes
3a65836e02 Bump version 2023-06-05 09:20:00 +10:00
Damien Elmes
e2f33bd646 Top-level prettier files should no longer be required
Exclusion is handled by dprint, and prettier conf is embedded in
.dprint.json.
2023-06-01 11:13:14 +10:00
Damien Elmes
e63b4b9927 Experiment with disabling prettier whitespace sensitivity
Prettier by default tries to preserve whitespace around inline tags,
which can prevent problems such as a space before the period in
'<a>text</a>.':

https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting

Unfortunately only standard HTML block elements are excluded from this
behaviour, so all of our Svelte components are treated the same way, even
if they are block-based, or used in a way where the extra whitespace
doesn't matter. This makes the code somewhat harder to read.

Changing this option does carry the risk that rogue spaces will creep
into our UI in the future as code is formatted, but as there don't appear
to be any such issues with this initial reformat, I think the improved
readability may justify the relatively small risk.
2023-06-01 11:11:26 +10:00
Damien Elmes
06a5ada99b Apply Latin1 fix to other platforms
While much less likely on other platforms (with no current reports and
/Applications or /usr/share folders being the norm), the issue
could still occur.
2023-05-31 16:41:12 +10:00
Damien Elmes
aa9a734f69 Workaround Ubuntu ignoring tooltip palette in dark mode
https://forums.ankiweb.net/t/tooltip-hover-appearance-looks-strange/30384
2023-05-31 15:19:10 +10:00
Damien Elmes
1e00b7d4c4 Expose onUpdateHook/onShownHook via package 2023-05-31 15:19:09 +10:00
Damien Elmes
88f613aaf0 Update translations 2023-05-31 13:49:35 +10:00
Damien Elmes
7c96a6c5e1 Add link to website in README
Closes #2528
2023-05-31 13:49:19 +10:00
Abdo
3787699f8c
Disable Toggle Bury when nothing is selected (#2529) 2023-05-31 13:47:43 +10:00
Damien Elmes
f758b33346
Default to current deck in csv import if settings allow it (#2527)
* Default to current deck in csv import if settings allow it

Reuses defaults_for_adding(). In the future we might also want to update
the last deck/notetype on successful completion, if entries weren't
specified in the file.

https://forums.ankiweb.net/t/importing-new-notes-to-wrong-deck-in-anki-2-1-63/30598

* Address review feedback from Rumo
2023-05-31 13:47:12 +10:00
Damien Elmes
7f6c410ca5
Various changes to I/O handling (#2513)
* Store coordinates as ratios of full size

* Use single definition for cappedCanvasSize()

* Move I/O review code into ts/image-occlusion

A bit simpler when it's all in one place.

* Reduce number precision, and round to whole pixels

>>> n=10000
>>> for i in range(1, int(n)): assert i == round(float("%0.4f" % (i/n))*n)

* Minor typing tweak

So, it turns out that typing is mostly broken in ts/image-occlusion.
We're importing from fabric which is a js file without types, so types
like fabric.Canvas are resolving to any.

I first tried switching to `@types/fabric`, which introduced a slew of
typing errors. Wasted a few hours trying to address them, before deciding
to give up on it, since the types were not complete. Then found fabric
has a 6.0 beta that introduces typing, and spent some time with that, but
ran into some new issues as it still seems to be a work in progress.
I think we're probably best off waiting until it's out and stabilized
before sinking more effort into this.

* Refactor (de)serialization of occlusions

To make the code easier to follow/maintain, cloze deletions are now decoded/
encoded into simple data classes, which can then be converted to Fabric objects
and back. The data objects handle converting from absolute/normal positions, and
producing values suitable for writing to text (eg truncated floats).

Various other changes:

- Polygon points are now stored as 'x,y x2,y2 ...' instead of JSON in cloze
divs, as that makes the handling consistent with reading from cloze deletion
text.
- Fixed the reviewer not showing updated placement when a polygon was moved.
- Disabled rotation controls in the editor, since we don't support rotation during
review.
- Renamed hideInactive to occludeInactive, as it wasn't clear whether the former
meant to hide the occlusions, or keep them (hiding the content). It's stored
as 'oi=1' in the cloze text.

* Increase canvas size limit, and double pixels when required.

* Size canvas based on container size

This results in sharper masks when the intrinsic image size is smaller
than the container, and more legible ones when the container is smaller than
the intrinsic image size.

By using the container instead of the viewport, we account for margins,
and when the pixel ratio is 1x, the canvas size and container size should
match.

* Disable zoom animation on editor load

* Default to rectangle when adding new occlusions

* Allow users to add/update notes directly from mask editing page

* The mask editor needs to work with css pixels, not actual pixels

The canvas and image were being scaled too large, which impacted
performance.
2023-05-31 13:45:12 +10:00
Abdo
c87f62487b
Add add-on installation hooks (#2523)
* Add add-on installation hooks

* Fix GUI code run in background thread

deleteAddon() is run in the background in the update routine so it
shouldn't containg any GUI code.

* Add a hint to the docstrings (dae)
2023-05-29 19:47:49 +10:00
Damien Elmes
93e1a6be22 Only apply Wayland workaround in Wayland path
https://github.com/ankitects/anki/issues/1767#issuecomment-1562695240
2023-05-29 19:07:54 +10:00
Damien Elmes
b618ab93a5 Update hakari and licenses 2023-05-29 17:54:00 +10:00
Damien Elmes
489f0fd066 Continue with install if old installer fails
User may have manually removed files, or the installation may be corrupt.

https://forums.ankiweb.net/t/installing-anki-when-there-seems-to-be-a-previous-version/30621
2023-05-29 15:07:44 +10:00
Damien Elmes
921e8c7985 percent-encoding -> percent-encoding-iri
Closes #2526
2023-05-29 14:46:02 +10:00
Damien Elmes
cc45789c02 Update translations 2023-05-29 13:36:07 +10:00
Damien Elmes
16c8c9cadc Fix broken styling when path includes certain Latin1 chars
https://forums.ankiweb.net/t/bug-2-1-64-the-updated-version-of-anki-is-causing-functionality-problems-with-autohotkey-and-goldendict/30575/5
2023-05-29 13:35:45 +10:00
Damien Elmes
f3147ce727 Opt in to new sparse index handling
https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html
2023-05-29 12:35:08 +10:00
chrissy0
70ce584d63
Making phrasing more clear in dialog which lets user choose a deck to display options for. (#2522) 2023-05-26 12:50:38 +10:00
Damien Elmes
15dcb09036
Detect incorrect usage of triple slash in TypeScript (#2524)
* Migrate check_copyright to Rust

* Add a new lint to check accidental usages of /// in ts/svelte comments

* Fix a bunch of incorrect jdoc comments

* Move contributor check into minilints

Will allow users to detect the issue locally with './ninja check'
before pushing to CI.

* Make Cargo.toml consistent with other crates
2023-05-26 12:49:44 +10:00
Abdo
8d1e5c373b
Fix some add-on installation errors not being reported (#2518) 2023-05-25 13:15:11 +10:00
Damien Elmes
e100789d24 Update requests for CVE
CVE-2023-32681
2023-05-24 16:09:15 +10:00
Damien Elmes
1ec6901933 Bump version 2023-05-24 16:07:43 +10:00
Damien Elmes
7686cb8de8
Fix misaligned image occlusions (#2512)
* Cloze styling is not required in I/O notetype

* Use raw string for IO template

* Rename to notetype.css and use more specific ids

* Move internal i/o styling into runtime

Storing it in the notetype makes it difficult to make changes, and
makes it easier for the user to break.

* Fix misaligned occlusions

At larger screen sizes, the canvas was not increasing above its configured
size, so it ended up being placed top center instead of expanding to fit
the entire container area.

To resolve this, both the image and canvas are forced to the container
size, and the container is constrained to the size of the viewport,
with the same aspect ratio as the image.

Closes #2492
2023-05-23 11:59:50 +10:00
Damien Elmes
581f82c589 Update translations 2023-05-22 14:08:46 +10:00
Ren Tatsumoto
9c5edfa88c
Ensure there's no duplicate shortcuts after running state_shortcuts_will_change (#2509)
* remove duplicate shortucts after running hook

* normalize shortcuts by converting them to QKeySequence

* no need to copy here

* extract method
2023-05-22 14:07:15 +10:00
Hikaru Y
d2176ff712
Fix page scrolling when input box loses focus (#2508)
… if page content exceeds viewport.

- Set 'opacity' to 0 instead of setting 'left' to a large negative
  value to create an invisible but focusable button.
- Prevent page from scrolling by setting 'left/top' to the values
  of 'scrollX/scrollY'.
2023-05-22 13:57:39 +10:00
Joel Koen
6b1c799cbf
Expose some collection methods already public in rslib backend (#2510)
* Expose some collection methods already public in rslib backend
2023-05-22 13:44:18 +10:00
Damien Elmes
878920712f Mention enter key
https://github.com/ankitects/anki/pull/2496/
2023-05-22 13:41:33 +10:00
Damien Elmes
cb3d2ff97a Move answer keys to right of dialog to reduce vertical space 2023-05-20 17:37:55 +10:00
Damien Elmes
644b003687 Fix Windows CI
The external file should be read at runtime, not compile time.
2023-05-20 11:20:16 +10:00
Damien Elmes
d715ac1675 Fix inability to start on Windows from a path that contains non-Latin text
Somewhat frustratingly, I only discovered this could be resolved with a
manifest change after first wasting hours trying to detect unicode text
in the NSIS installer, and warning the user that they'd need to change
their system locale if unicode text was found. Also tried adjusting the
locale with setlocale() on program startup, which did not help, perhaps
because it needs to be set before libc init.
2023-05-20 10:49:00 +10:00
Damien Elmes
c49ea40ddf Automatically add NSIS plugins as part of the bundle process
Avoids the need to manually copy them into place
2023-05-20 10:49:00 +10:00
Damien Elmes
c520b59311 Support prop queries in filtered decks
https://forums.ankiweb.net/t/phantom-overdue-reviews/30300
2023-05-20 10:49:00 +10:00
Damien Elmes
716db5ee6b Update translations 2023-05-18 18:08:56 +10:00
Ren Tatsumoto
a378e2923e
Allow the user to configure answer keys (#2502)
* add methods that allow the user to configure answer keys

* allow editing answer buttons in preferences

* import optional

* Give the layout referenced in code a clearer name (dae)

* Update placeholder text and make it translatable (dae)

The other items in the preferences screen don't have tooltips, so
placeholder text may be easier for the user to discover than a tooltip.
2023-05-18 17:47:51 +10:00
Martin Grottenthaler
f4f5844ca3
Implement non elevated installer (#2497)
* changed install location and elevation

* change registry keys to HKCU
change context to current user

* filetype associations non elevated

* added an "upgrade" from elevated to non elevated

* added comment to clarify bug

* removed commented out registry entries

* Update CONTRIBUTORS

add mgrottenthaler to contributors

* change upgrade routine to manual uninstall

* added suggestion
2023-05-18 17:06:38 +10:00
Hikaru Y
2fa63af9c2
Upgrade Svelte (#2506)
* Bump Svelte version

* Ignore Svelte a11y warnings
2023-05-18 17:04:58 +10:00
Damien Elmes
61555fef7d Hack around color setting failure in Qt6.5
Closes #2505
2023-05-18 16:36:16 +10:00
Damien Elmes
40a68afad3 Add the ability to search for custom data properties
Closes #2491
2023-05-18 15:54:01 +10:00
Damien Elmes
f1ddfb7af6 Fix inability to import csv when path contains single quote
https://forums.ankiweb.net/t/windows-10-2-1-62-qt6-blank-import-window/30231
2023-05-18 11:50:34 +10:00
Damien Elmes
a19cb75768 Fix broken media importing in non-legacy apkg path
- Ensure our unit tests cover the non-legacy path, and check file
contents and not just existence.
- Pass `compressed` into copy_and_ensure_sha1_set(). We can't just
test for self.sha1.is_none(), as that fails in the case where an existing
media file was found in the legacy path.

https://forums.ankiweb.net/t/anki-media-file-corruption-when-exporting-png-files/30315
2023-05-18 11:33:01 +10:00
Damien Elmes
63fd70ad34 Add a .with_desktop_media_paths() helper 2023-05-18 11:02:02 +10:00
Damien Elmes
cff613bfef Display a more informative message when attempting media op without folder 2023-05-18 10:48:25 +10:00
Damien Elmes
19b08eb280 Store separate state/geometry for each Qt minor version
Quite a few users have been experiencing crashes recently that were
resolved by resetting their window positions/states. I presume this is
related to Qt updates, as there have been previous instances where old
state caused glitchy behaviour or crashes after a Qt upgrade.

The browser headers are now also reset when resetting window positions
in the preferences.
2023-05-18 10:04:30 +10:00
Damien Elmes
4e65793966 Remove offset workaround in restoreGeom()
Way back in Qt4, there was an issue where (some?) windows would open
at a different location to where they were previously open. I've tested
the primary windows in Qt 5.14 on macOS, and the issue no longer seems
to exist, so this code is no longer useful.

The qtmajor > 5 check was a mistake introduced in 70dbd06be3ff56f13b9efe7c886c2a6c4f873ce9;
it was intended to limit the code to Qt 5.

A quick grep of an add-on snapshot indicates there are no add-ons that
were using the offset param, so it has been removed.
2023-05-18 10:04:30 +10:00