Commit Graph

1724 Commits

Author SHA1 Message Date
Abdo
6ef460e74a
Close MathJax editor when Esc is pressed (#2237) 2022-12-05 15:08:38 +10:00
Damien Elmes
8165f95cde Fix the wrong notetype being selected by default
Regressed in #2082

https://forums.ankiweb.net/t/anki-2-1-55-beta-7/25130/7
2022-12-05 15:08:00 +10:00
Damien Elmes
fad1ff7467 Tweak graph margins again
2860ee1424 (commitcomment-91940936)
2022-12-04 21:50:58 +10:00
Damien Elmes
1ca05b00ec Exempt MathJax images from image shrinking
https://forums.ankiweb.net/t/anki-2-1-55-beta-mathjax-preview/23529/18
2022-12-04 20:03:27 +10:00
Damien Elmes
2860ee1424 Fix graphs not taking up full width 2022-12-04 19:48:18 +10:00
Damien Elmes
a05174b411 Collapse margins on narrow screens 2022-12-04 19:47:03 +10:00
Damien Elmes
2531a4dab6 Fix pie chart disappearing in 2/3 column graph modes 2022-12-04 19:24:37 +10:00
Damien Elmes
0ebe70fe23 Bump Mathjax version 2022-12-04 18:01:26 +10:00
Damien Elmes
9d2b3fe1c8 Fix deck options sticky hiding itself 2022-12-04 15:07:48 +10:00
Damien Elmes
0311e2528e Make the NoData overlay match the normal background color 2022-12-04 14:49:04 +10:00
Damien Elmes
d52aa77b29 Add some left/right margins to congrats page 2022-12-04 13:58:50 +10:00
Damien Elmes
3d8c7f5ea1
Rework spinner buttons (#2230)
* Align spinner buttons on right

The initial rationale for splitting them up was to be more touch friendly,
but we won't be able to use them on mobile anyway due to the conflicts
with double taps zooming in. On desktop, having them apart requires more
mouse movement when overshooting, so it's better to have them in one
place.

Text is now left-aligned again, which matches our other inputs like
learning steps.

The left/right buttons have been changed to up/down, which matches our
Qt spinners, and avoids RTL concerns.

This commit also removes the border on hover/select - it caused the
left-aligned content to flicker, and didn't look correct. Perhaps we could
add it back in a better way in the future.

* Hide spinner buttons on mobile devices

Tapping on them conflicts with the page zoom gesture.

* Remove min-height on spinner buttons

* Only show spinner on hover

Since they're only useful with a mouse, and only useful when they're
under the cursor, hiding them when focused keeps things less cluttered.
2022-12-04 13:18:49 +10:00
Damien Elmes
ed45adcb08 Partially revert #2215
This fixes the issues mentioned on 
https://forums.ankiweb.net/t/anki-2-1-55-beta-5/24870/78

I can't seem to reproduce the extra tag being added when auto-completing
anymore, but perhaps I'm just not getting the steps right.
2022-12-04 11:37:16 +10:00
Damien Elmes
7f5e3c8106 Add env var to enable sourcemaps
They slow down the build, so are not on by default.
2022-12-04 11:37:16 +10:00
Damien Elmes
ecfa557043 Skip minify in debug builds 2022-12-04 10:05:16 +10:00
Damien Elmes
65fd1a6772 Revert to old select in change notetype screen for now
Fixes https://forums.ankiweb.net/t/anki-2-1-55-beta-5/24870/25,
introduced in #2082
2022-12-03 23:04:08 +10:00
Damien Elmes
7761f609a0 Fix typed text not being saved if saving immediately
https://forums.ankiweb.net/t/anki-2-1-55-beta-5/24870/43
2022-12-03 22:41:17 +10:00
Damien Elmes
1a444f30e9 Fix formatting inside selection not being removed
Regression introduced in #2017 while fixing another bug.

Closes #2072
2022-12-03 21:41:54 +10:00
Matthias Metelka
9c45a2f7d0
Refactor Select component | Fix CSV import issue (#2227)
* Refactor Select component and implement/update it in various screens

* Remove redundant select CSS

* Tweak DeckOptionsPage

* Fix CSV import layout

* Fix save button margin in change notetype screen

* Fix sticky header positioning

* Remove unused imports

* Make StickyHeader sticky instead of fixed
2022-12-01 19:24:26 +10:00
Matthias Metelka
9ecc0ffdc6
Use third grid column in graphs layout on wide screens (#2226)
* Use third grid column on graphs page when width > 1400px

* Define column width more precisely

* Center graphs inside containers

* Fix graphs always showing 2+ columns (dae)
2022-12-01 16:33:52 +10:00
Matthias Metelka
a48c96559d
Fix glitchy animation of floating elements (#2224)
* Set max-height of 400px to scrollable Popover

* Pass computed placement to user components

to set different animation directions when the placement changes.

* Move elevation effect from WithFloating/WithOverlay to Popover

* Apply same changes as in WithFloating to WithOverlay

* Adjust FloatingArrow CSS to Popover

* Run eslint and formatter
2022-12-01 15:45:52 +10:00
Matthias Metelka
1ab4ee38c6
Refactor SpinBox component (#2223)
this fixes the increment button not showing.
2022-12-01 15:34:54 +10:00
Matthias Metelka
43ce4cacc6
Give containers brighter color than canvas (#2220)
* Give deck browser table an elevated container look

* Tweak colors of elevated containers (e.g. in deck options)

* Prepare editor fields for custom backgrounds

* Tweak field margin and add explanatory comment
2022-11-29 17:54:42 +10:00
Damien Elmes
b2049209ff Re-enable formatting for .ts files
There are some style differences compared to prettier, and not all are
necessarily an improvement, but it's much faster now.
2022-11-28 09:33:04 +10:00
Damien Elmes
ea5153e7a4 Re-enable formatting for .svelte files 2022-11-28 09:17:39 +10:00
Damien Elmes
5e0a761b87
Move away from Bazel (#2202)
(for upgrading users, please see the notes at the bottom)

Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.

For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).

Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.

These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:

- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.

I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.

The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.

This new build system should result in faster builds in some cases:

- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.

As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.

Some other changes of note:

- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.

If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:

- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed  (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
  place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
2022-11-27 15:24:20 +10:00
Matthias Metelka
88362ba1f7
Make dropdown text smaller than page text by default (#2216) 2022-11-27 10:47:31 +10:00
Matthias Metelka
6c6a10c142
Fix some issues with the Tag Editor (#2215)
* Prevent global focus border on tag-input

* Fix margin issues with tag editor

* Remove redundant autocomplete call

that caused the addition of an empty tag when tag suggestions were selected with the Enter key.

* Prevent input text from overlapping with newly added tags

... at least when they're selected from the autocomplete list via mouse. If they're selected via keyboard, there's still an overlapping issue.

* Fix error on updateSuggestions

* Hide empty tag

* Make double-click to collapse/expand translatable
2022-11-27 10:45:33 +10:00
Hikaru Y
8f2f62c466
Fix shortcuts for tag actions not working (#2214) 2022-11-27 10:29:58 +10:00
Stefan Kangas
5551a37f03
Fix typos (#2210) 2022-11-24 20:18:57 +10:00
Matthias Metelka
365c5e1fb2
UI size tweaks (#2184)
* Reduce font size of answer button indicators

* Increase padding of browser rows with ResizeToContents on vertical header

* Remove 0.8 scale factor for dropdown item font-size

* Remove font-size prop entirely from DropdownItem

* Revert "Remove font-size prop entirely from DropdownItem"

This reverts commit bb0a158f96183cca74e198867070c2f99af04dc4.

* Remove hard-coded Python font sizes

* Move font size and scrollbar into _root-vars.scss

* Revert editor size variable to 1.6

* Fix icon alignment

* Fix checkbox alignment for dropdown items

* Remove unused classes from Tag.svelte

* Revert "Increase padding of browser rows with ResizeToContents on vertical header"

This reverts commit 77bfc854ba140dd99aae98efcdd4af7052615fa6.

* Remove option to set font size of browser entries

* Add setting for browser row padding to preferences

* Revert "Add setting for browser row padding to preferences"

This reverts commit 75c59da65a1028e2caa3c48b247f99825c1b0b6c.

* Revert "Remove option to set font size of browser entries"

This reverts commit a543783d8ea079f39b7ae445152573c96be29841.
2022-11-23 16:50:15 +10:00
Matthias Metelka
fdfdd67c3a
Revert to pseudo-element approach for field description (#2209)
* Revert to pseudo-element approach for field description

to ensure it changes on update.

* Simplify CSS
2022-11-23 16:37:12 +10:00
Matthias Metelka
e9430fde3b
Give OptionsButton its own ButtonGroup and move it to more prominent position (#2207)
and give it some padding
2022-11-23 16:18:29 +10:00
Matthias Metelka
fba46e9815
Fix Floating Ui error causing freezes on image resize (#2206)
* Replace autoPlacement with flip

* Remove logic made redundant by use of flip()

* Edit preferred placement on components using WithFloating

* Rename placement to preferredPlacement

* Set "bottom" as default placement and remove redundant declarations
2022-11-23 16:16:09 +10:00
Hikaru Y
ad4acf90ef
Fix TagsSelectedButton's popup appears in wrong position (#2197) 2022-11-21 10:14:01 +10:00
Abdo
434287a50a
Fix inverted Ctrl+right/left handling in RTL fields (again) (#2191) 2022-11-15 11:14:18 +10:00
Matthias Metelka
d902b00d0e
Fix reduce motion bottom border issues (#2185)
* Fix reduce motion bottom border issues

* Disable show/hide on hover with reduce motion setting

for purists.
2022-11-08 22:57:10 +10:00
Matthias Metelka
96381f3f2c
Make dupes highlight persist on field blur (#2182) 2022-11-05 11:05:21 +10:00
Matthias Metelka
03fe2385ef
Fix HTML editor not showing content initially (#2181)
* Fix HTML editor not showing initially

* Remove line numbers from PlainTextInput
2022-11-05 10:58:04 +10:00
Matthias Metelka
c60a1c8ebd
Remove inset shorthand property for Qt5 support (#2180) 2022-11-05 10:55:17 +10:00
kelciour
3973f27ee4
Maybe preload images (#2165) 2022-11-04 10:07:51 +10:00
Matthias Metelka
fd2212a6cb
Prevent deck options switches from toggling on label click (#2166)
* Prevent deck options switches from toggling on label click

because the label click is reserved to open the help modal.

* Add option to prevent mouseclick event to Label.svelte
2022-11-04 10:06:57 +10:00
Damien Elmes
84935bee34 Fix wrong deck options being selected by default
We were sorting in getConfigList() without updating selectedIdx. For some
reason, this worked in the past, but something about #2084 stopped it
from working correctly. Resolved by sorting+updating selectedIdx after
adds/renames, instead of in getConfigList(). This required changes to
the unit tests, as the indexes are different now.

Fixes https://forums.ankiweb.net/t/anki-2-1-55-beta-3/24295/58
2022-11-03 12:50:16 +10:00
Damien Elmes
c9a9f38ea9 Remove untranslated 'see old deck options' notice
It was intended to be a temporary message, and it's been about 15 months.

https://forums.ankiweb.net/t/anki-2-1-55-beta-3/24295/42
2022-11-03 12:05:19 +10:00
Damien Elmes
23ef52a297 Avoid sticky containers in importing screen for now
Section content is being obscured under the headings, causing settings
not to be seen, and text to appear in unusual places like under the
importing bar at the bottom. Until a better solution can be found, this
should allow things to be shown properly.

https://forums.ankiweb.net/t/anki-2-1-55-beta-3/24295/27
2022-11-03 11:59:08 +10:00
Damien Elmes
ef933f9975 Fix MathJax pop-up appearing at bottom of screen
Closes #2174
2022-11-03 11:47:31 +10:00
Damien Elmes
a0e403c3dd Allow passing startup props to setupCardInfo()
Add-ons that use it and don't want the revlog can pass in includeRevlog:false

Issue noticed while addressing https://forums.ankiweb.net/t/card-info-during-review/86/12
in c86da082b4
2022-11-03 11:37:47 +10:00
Matthias Metelka
27eff12235
Fix various RTL issues (#2172)
* Fix RTL issues in deck browser

* Fix RTL issues in deck options

* Fix QMenu indicator being cutoff in RTL mode
2022-11-02 21:47:07 +10:00
Matthias Metelka
2a510fe230
Set same font size for all platforms and make editor UI a bit smaller (#2171)
* Use single base font size for all platforms

* Change 1.6em values to 1.5em in editor
2022-11-02 21:33:35 +10:00
Matthias Metelka
d3309658d3
Fix fields not showing with reduce motion active (#2170)
* Fix fields not showing with reduce motion active

* Fix CSS selector
2022-11-02 20:44:53 +10:00