Commit graph

51 commits

Author SHA1 Message Date
Henrik Giesel
6f31ab5990 Prefer event.which over event.{key,code}
It works better with alternative Latin-based keyboard layouts
2021-05-22 17:50:23 +02:00
Henrik Giesel
5cbda88605 Base shortcuts with letters no event.key, with symbols/numbers on event.code 2021-05-21 22:45:55 +02:00
Henrik Giesel
cc15145a0b Make numpad keys also cancel current shortcut sequence 2021-05-21 19:03:06 +02:00
Henrik Giesel
21cf99d612 Capitalize keyboard shortcut letters 2021-05-20 18:46:22 +02:00
Henrik Giesel
3145e4884f Instead of timeouts, make non-related keypresses cancel shortcut sequences 2021-05-20 18:32:53 +02:00
Henrik Giesel
abf1418695 Switch to keyboard shortcuts based on event.key 2021-05-20 18:28:59 +02:00
Damien Elmes
5bd3884a71 support card state mutator in test scheduler
Documentation to come
2021-05-17 16:59:02 +10:00
Damien Elmes
eefdd564e2 remove nested terneries and enable lint
@hgiesel would you mind quickly checking I've correctly captured
the logic here?
2021-04-23 13:00:18 +10:00
Damien Elmes
5e37cb7561 move isApplePlatform() into lib/shortcuts, and remove sveltelib file 2021-04-23 11:22:30 +10:00
Henrik Giesel
31eaeef09b Rename anki/ to lib/ for export
import _ from "anki/x";

will become

import _ from "lib/x";

to fit the directory name.
2021-04-23 10:02:28 +10:00
Henrik Giesel
d4e6fe6a34 Prefer optionalModifiers over register multiple shortcuts 2021-04-22 18:15:25 +02:00
Henrik Giesel
4ebad6f173 Add optionalModifiers parameter to registerShortcut 2021-04-22 17:28:38 +02:00
Henrik Giesel
33fc648695 Add license headers 2021-04-22 16:49:30 +02:00
Henrik Giesel
363469dc36 Satisfy formatter 2021-04-22 15:24:27 +02:00
Henrik Giesel
469c138ec1 Add shortcut labels for ColorPicker and Latex items 2021-04-22 14:35:44 +02:00
Henrik Giesel
7c2ac1fd37 Add getPlatformString for making shortcuts to platform string 2021-04-22 13:04:24 +02:00
Henrik Giesel
e2e1b4d37b Use registerShortcut within WithShortcut 2021-04-22 01:15:38 +02:00
Henrik Giesel
3b52bf6cb8 Add lib/shortcuts 2021-04-22 01:15:38 +02:00
Damien Elmes
de5f892807 allow postrequest to send a binary body; fix WithGraphData
As far as I can tell, the existing code was transforming the encoded
protobuf data into UTF8, and we're just lucky it wasn't causing problems
with the small message we were sending.
2021-04-20 17:47:52 +10:00
Damien Elmes
c0e615ddde support es6 imports in Jest tests
Switching to lodash-es caused Jest to fail. The standard Jest workflow
would be to transpile things with Bazel, but we can do it faster by
bundling with esbuild.

the log in lib.test.ts has revealed numbers are being set as Long instead
of JS numbers, and the published workaround for it is not working :-(
2021-04-17 16:38:45 +10:00
Damien Elmes
168af33aa8 add macro for invoking Jest 2021-04-16 23:46:31 +10:00
Damien Elmes
72193c45ec more experimental updates to deck config screen
- try out bootstrap modals - they're not perfect, but let's see how
they go for now. Won't be hard to switch to bridge commands if required.
- handle adding/renaming/removing
- add a class to manage the state
2021-04-16 23:29:21 +10:00
Damien Elmes
2a43d42323 run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
1f475a1709 add missing copyright headers to *.ts 2021-04-13 18:57:08 +10:00
Damien Elmes
c6da01c4aa disable Jest tests on Windows again
It looks like the templated_args change only masked the error last time;
Jest seems broken on Windows with both the patched .24 version, latest
stable, and the new beta version too, presumably because symlinks are
being handled differently on Windows somehow. It might be possible to
hack around the issue by patching the following file, but I'm not sure:

https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/crawlers/node.ts
2021-04-12 15:39:46 +10:00
Damien Elmes
9d03e266e3 add naturalWholeUnit() and basic tests to lib/time.ts
naturalWholeUnit() is not currently used
2021-04-12 14:42:06 +10:00
Damien Elmes
125dcee811 remove obsolete comment 2021-03-26 21:47:23 +10:00
Damien Elmes
0006a385e1 allow js to request specific i18n modules
Brings the payload on the congrats page with a non-English language
down from about 150k to 15k
2021-03-26 21:43:36 +10:00
Damien Elmes
5ef9282f9b fix handling of variables that don't match ts naming style 2021-03-26 21:34:24 +10:00
Damien Elmes
00eb89c2ec use singleton + free functions for i18n in ts
This allows for tree shaking, and reduces the congrats page from 150k
with the old enum solution to about 80k.
2021-03-26 20:38:44 +10:00
Damien Elmes
b145b04ddf drop legacy enum from ts/ 2021-03-26 19:26:35 +10:00
Damien Elmes
6cde7ff536 update remaining TR references in ts/ 2021-03-26 19:24:48 +10:00
Damien Elmes
0e50259e6b update TR references with args in *.ts; fix average answer time 2021-03-26 19:10:39 +10:00
Damien Elmes
efb92d5ee9 generate ts methods for translations 2021-03-26 18:11:58 +10:00
Damien Elmes
0c63a7c8c4 rework translation handling
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.

This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.

The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.

Other changes:

- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
2021-03-26 09:41:32 +10:00
Damien Elmes
72885bc710 move to new rules_nodejs protobuf example to unblock upgrade
@hgiesel the tag editor will need to add the following to the rollup
deps:

        "//ts/lib:backend_proto",
        "//ts/lib:fluent_proto",
2021-03-20 10:24:32 +10:00
Damien Elmes
33e532166a Revert "sanitize deck description HTML with html-sanitize"
This reverts commit cd37a9ae83.
2021-02-06 13:25:40 +10:00
Damien Elmes
cd37a9ae83 sanitize deck description HTML with html-sanitize
Committing for reference; will roll back afterwards.

This adds approximately 150k to the bundled .js file in release mode.
html-sanitizer might be useful to replace our custom paste filtering
code in the future, but for now I'm not sure it's worth the extra
page load time over doing the filtering in Rust.
2021-02-06 13:25:34 +10:00
Damien Elmes
45ec14184a show actual error when graphData fails
The original reason for the catch-all message was users with bad
data such as decimal intervals, but those get automatically coerced
these days. The common case should now be invalid search strings, which
we can show verbatim.
2021-01-29 14:39:05 +10:00
Henrik Giesel
45ff094392 Add bridgeCommand helper function 2021-01-26 01:25:54 +01:00
Henrik Giesel
e509b768ff Get weekday labels via Date.prototype.toLocaleString 2021-01-21 19:38:56 +01:00
Henrik Giesel
3fa5f20344 Fix one-off error for Histograms:
examples:
* x0 = -66 and x1 = -64 should yield 65-66 days ago instead of 64-65 days ago
* x0 = -2 and x1 = 0 should yield 1-2 days ago instead of 0-1 days ago
2021-01-07 17:14:31 +01:00
Henrik Giesel
45fe3794ec Add gatherByQueue and gatherByCtype methods 2021-01-04 14:04:51 +01:00
Damien Elmes
6cac9c4a5b remove empty es6 group; reference original ts_library instead 2021-01-02 21:18:10 +10:00
Damien Elmes
3973266596 plural rules and decimal separator should use bundle's language
Instead of providing the list of languages in preferred order, when
creating a bundle we need to specify the bundle language as the first
language, so that the correct plural rules are used. Fluent's docs
are misleading here; I will submit a PR to fix them.

The old behaviour caused:
https://forums.ankiweb.net/t/bug-in-review-intervals-for-some-languages-in-number-of-cards/5744
2020-12-14 14:23:49 +10:00
Damien Elmes
a4af59fc4d format_fix -> format; rename svelte-check for consistency 2020-11-12 20:19:32 +10:00
Damien Elmes
4f8b19dcfb fix external consumption of ts rules, and simplify import path 2020-11-05 11:01:52 +10:00
Damien Elmes
7c27c4b9a0 move backend.proto into rslib/ 2020-11-02 16:28:31 +10:00
Damien Elmes
ce3b08ac58 initial Bazel conversion
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:

- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.
2020-11-01 14:26:58 +10:00
Damien Elmes
45083f3caa compile typescript in one go
much faster, especially with --incremental
2019-12-18 14:33:57 +10:00