* Enable strict_optional for aqt/editor.py
* Fix mypy errors in EditorWebView class
* Fix mypy errors in Editor class
* DRY
* Match same short circuiting behavior
* Convention
* Fix 'Discard changes' dialog appearing even when no changes are made
https://forums.ankiweb.net/t/anki-24-10-beta/49989/166
* Fix geometry of deck options window not being saved
evt.accept() does not seem to trigger reject().
* add get_revlogs API
* fix tooltipText of ReviewsGraph
the style of true-retention shouldn't affect the style of tooltipText of ReviewsGraph
* More verbose wording (dae)
* typeanswer: cleanup
* DiffNonCombining's new() used String where plain Vec is appropriate
* get rid of normalize_typed for DiffTrait again by pulling code into DiffNonCombining's new()
* two DiffNonCombining testcases
* typeanswer: return to NFC & typos
There are only two types of actions. The code does not seems to
consider this to be extandable, and the changed variable is private,
so I would expect it relatively acceptable to change the way it
work. This would improve the typing.
If this is rejected, at least, the callback should be noted as
optional, so that the IDE does not complain that `if cb` can not be
false.
* Prevent memory leak
* Fix deck option changes not detected until focus is lost
* Accurately determine if there are any pending changes
This makes it so that the confirmation dialog appears when it should,
and not when it shouldn't.
* Add "open image" option to editor
* Update qt/aqt/editor.py
Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
* Update editor.py
* Remove unused import
* Fix "show in folder"
* Fix 'show in folder' on macOS
* Revert "Fix "show in folder""
This reverts commit cf2b33ee9422bcaf8d9e20bd4cce74e5061c13cf.
* Reimplement show_in_folder for Windows (dae)
- Avoid reusing call(), as the startupinfo we were passing in was
breaking the explorer invocation
- Attempt to bring explorer to the front after the window has been show,
as it otherwise appears under Anki (at least when running from source)
---------
Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
* typeanswer: fix cleanup
Fix: Add prepare_expected back in for the 'nothing typed' & 'correctly typed' cases. This also makes expected_original redundant again.
Style: %s/provided/typed/g
Style: rename one ch → c
Testcase: whitespace_is_trimmed: added a check for the "correctly typed" path and renamed it to tags_removed (there's no whitespace?)
Testcase: empty_input_shows_as_code: changed to also check that tags get trimmed
* [type:nc] – ignores combining characters
Adds a comparison variant to [type] which ignores when combining characters of the expected field are missing from the provided input. It still shows these characters in the 'expected' line for reference.
It's useful for languages with e.g. diacritics that are required for reference (such as in dictionaries), but rarely actually learned or used in everyday writing. Among these languages: Arabic, Hebrew, Persian, Urdu.
The bool 'combining' controls it as new final parameter of both relevant compare_answer functions. On the Python side, it's set to true by default.
Use on the note templates: [type:nc:field] (only the front needs to include :nc)
This also removes the need to have both variants of words/sentences present as separate fields, to show them redundantly, etc.
* typeanswer: simplify by using nfkd throughout
Requires adjusting two testcases, but both render exactly the same in Anki itself.
On NFC vs. NKFD: https://stackoverflow.com/a/77432079
* typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)
I'd prefer to keep this extra method.
* typeanswer: micro-optimize vectors
Should get rid of most relocations, at the expense of over-allocating.
On Vec's (String's) behavior: https://stackoverflow.com/a/72787776
* Mark `combining` as private
typeCorrect is not marked as private either, but we can at least do
the right thing for newly-added code.
* Revert "typeanswer: micro-optimize vectors"
This reverts commit 9fbacbfd19.
* Revert "typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)"
This reverts commit df2dd3394e.
* add name to about page
* use two decimal retention for calculations
* Update CONTRIBUTORS
* format
* Update CONTRIBUTORS
* Update CONTRIBUTORS
* Update CONTRIBUTORS
* If deck options are modified, ask before closing
This imitates the way the note editor behaves. If a user assumes by
error that chanhges are automatically saved, it ensures they won't
lose them.
Also, this will eventually allows to have the same feature on
AnkiDroid. While, currently, we always ask the user whether they want
to close the deck options, even when there are no modification, which
seems to regularly frustate users (including myself).
I'm new to Svelte, please let me know whether there is a better way to
obtain the information from Svelte state that I missed.
Note that I ensured that only a boolean can be obtained. I didn't
cause the whole state to be accessible. May be useful for some
add-ons, I guess, but risks breaking too much things.
Regarding the deckoptions.py, I tried to imitate addcards.py way to
check whether the add card view can be closed. Reusing the same
function and variable name when possible.
* Update qt/aqt/deckoptions.py (dae)
* Updated error message to provide additional guidance for file import issues if Legacy Import/Export is enabled
Enhanced the error message from "Unable to read file. It probably requires a newer version of Anki to import."
to include a suggestion for users to try unchecking 'Legacy import/export Handling' under Preferences > Editing >
Import/Export if they encounter the issue.
* Update CONTRIBUTORS
* refactor: fix type checking error
error: Argument 1 to "_answerCard" of "Reviewer" has incompatible type "int"; expected "Literal[1, 2, 3, 4]" [arg-type]
* refactor: remove check that `ease` is correct number
* refactor: rename variable
* refactor: add type hint for generator function
* refactor: revise import of `functools.partial`
* refactor: invert logic of if-construct
to avoid nesting.
* refactor: properly check for `None`
* Update qt/aqt/reviewer.py
* test using existed cards
* plot new and review
* convert learning cards & use line chart
* allow draw multiple simulations in the same chart
* support hide simulation
* convert x axis to Date
* convert y from second to minute
* support clear last simulation
* remove unused import
* rename
* add hover/tooltip
* fallback to default parameters
* update default value and maximum of deckSize
* add "processing..."
* fix mistake
* right click and copy on image works
* renamed helper fn
* separated functionality of copy and copy image
* Update CONTRIBUTORS
* snake case
* Update CONTRIBUTORS
* Add AnkiHub section to preferences screen
* Add short intro for AnkiWeb and AnkiHub to syncing section
* Add AnkiHub login screen
* Implement login methods in backend
* Set minimum dialog width
* Add missing colon
* Respect the ANKIHUB_APP_URL env var
This is used by the add-on.
* Simplify login error reporting
* Fix from_prefs_screen not passed to subcall
* Add missing ankihub_pb2 import
* Install AnkiHub add-on after sign-in
* Avoid .exec()
* Update ftl/core/sync.ftl
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* Split translation string
* Support login by username/email
* Fix entered username/email not being passed back to on_done
* Remove unused import
* Move to 'Third-party services' section
* Tweak login dialog's heading
* Remove 'third-party' from intro text
* Tweak copy
* Prefix profile keys
* Tweak strings
* Remove description from login dialog
* Remove signup links
* Clear credentials in ankihub_logout()
* Call .adjustSize()
* Title Case
* Add padding to third-party services, and fix tab order from other PR
* fix: except only non-system-exiting exceptions
see https://youtu.be/zrVfY9SuO64
* chore: add myself to CONTRIBUTORS file
* refactor: explicitly specify possible exceptions
If an exception is not an Exception, there are only three options left.
see https://docs.python.org/3/library/exceptions.html#exception-hierarchy
* refactor: use BaseException for fallback
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* chore: add myself to contributors
* fix: ensure none of the returned values is None
Fixes TypeError 'NoneType' object is not subscriptable
* refactor: reduce code duplication using a function
* refactor: prefer KeyError over None for dicts
If the key is not in the dictionary, we want to raise a KeyError rather
than returning None. That way, we can distinguish between whether the
value was None or the key was not found.
* chore: add myself to CONTRIBUTORS file
* refactor: simplify the code
* chore: add myself to CONTRIBUTORS file
* refactor: use newer type hints for Union/Optional
* refactor: fix deprecated type annotations
use collections.abc rather than typing
* refactor: use lower letter type annotations
* style: reformat with black
* refactor: remove unused imports
* refactor: add missing imports for type hints
* fixup! refactor: use newer type hints for Union/Optional
* fix: add missing imports for type annotations
* fixup! refactor: use newer type hints for Union/Optional
* fixup! style: reformat with black
* refactor: fix remaining imports re: type hints
* chore: remove isort settings covered by profile
https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#custom-configuration
* chore: add myself to CONTRIBUTORS file
* chore: use black profile for isort
* chore(isort): fix configuration to skip directories
When overwriting `skip`, `.git` and others would no longer be skipped.
`extend_skip` is the correct option.
* chore(isort): skip directory `qt/bundle`
* changed anki-logo-thin.png to version with transparent background
* Revert "changed anki-logo-thin.png to version with transparent background"
This reverts commit 4c7e826a73.
* changed anki-logo-thin.png to version with transparent background
* added name to contributors as per contribution guidelines for first PR
* fixed contributors file rather than directly modifying about file
* Configure buddy widgets for labels in the Preferences dialog
Labels are often used to describe the purpose of a different widget like a combobox, edit field or a spinbox by providing a textual name for their functionality. The relation between a label and a widget is typically expressed by placing the label next to the relevant object. In addition to this visual linking intended for human users, frameworks usually also offer semantic way to link labels with other widgets, so the relation can be noticed by programs like screenreaders, which can figure out the correct textual description for the focused widgets based on this information.
By default, labels on their own are not focusable elements, so users dependend on keyboard navigation and speech get to notice only the widget types (textbox, spinbox, etc.) while moving around without any contextual information if labels are not linked. When the linking is done, the component names get included as well.
QT provides the "buddy" property for QLabel, which creates a semantic link between the label and its buddy widget.
This commit configures the buddy properties on labels of the Anki Preferences dialog.
* Configure spinbox suffixes in Preferrences dialog
QSpinBox provides a suffix property. This property makes it possible to display a measurement unit next to the component value, which is linked to it both visually and semantically for the GUI framework without affecting the spinbox value itself. For purposes of accessibility, it's better to use this property than simply place a label next to the component, since it can be directly accessed by screenreaders and other assistive technology.
This commit configures suffix properties for spinboxes in the Anki Preferences dialog. Note: Removal of the original unit labels may have altered the UI a little bit.
* Assign buddy widgets in the ID and password retrieval dialog
Set buddy widgets of the labels in the Get ID and password for synchronization dialog.
* Fix positioning/size of text boxes
* Style the suffixes of Preferences' QSpinBoxes
Style QSpinBox suffixes (for those that have one) in the Preferences dialog by prepending them by a space character.
This resulted in the I/O regression in #3223 not being caught with ./run,
and puts devs ast risk. It also does not currently seem to be required
(pages like graphs and deck options work correctly with ./yarn dev).
I suspect the change was made to support running of pages/*.html, which
we no longer build.
* Add a preference to toggle LaTeX generation
* Fix test
* Remove LaTeX security restrictions
* Show existing LaTeX images regardless of preference
* Lift config check out of loop (dae)
* Shift option to review settings; display warning when disabled (dae)
* Do not show media auto sync errors
* is_autosync -> is_periodic_sync
* More wording improvements; fix periodic sync depending on auto sync setting (dae)
* Add keyboard shortcuts for empty cards and toggle mask on image occlusion
- add shortcut for empty cards
- add shortcut for toggle mask
- set tooltips with shortcuts
use unused shortcut for empty cards
* remove unnecessary shortcut added in main.py
* change empty cards shortcut and try to fix CI error in CONTRIBUTORS
* change shortcut for empty cards for universal support
* Feature Question Action Show Reminder (#3064)
Added a option in the deck config that allow the user to choose in
Autoupdate mode between showing a reminder or revealing the card.
Also added my name to the contributors
* Update ftl/core/deck-config.ftl
This dependency usually doesn't benefit Linux distros with requests library configured to use system certificate already. And is not packaged by most distros. Making it optional will make most Linux users' installation much easier.
* Update to latest Node LTS
* Add sveltekit
* Split tslib into separate @generated and @tslib components
SvelteKit's path aliases don't support multiple locations, so our old
approach of using @tslib to refer to both ts/lib and out/ts/lib will no
longer work. Instead, all generated sources and their includes are
placed in a separate out/ts/generated folder, and imported via @generated
instead. This also allows us to generate .ts files, instead of needing
to output separate .d.ts and .js files.
* Switch package.json to module type
* Avoid usage of baseUrl
Incompatible with SvelteKit
* Move sass into ts; use relative links
SvelteKit's default sass support doesn't allow overriding loadPaths
* jest->vitest, graphs example working with yarn dev
* most pages working in dev mode
* Some fixes after rebasing
* Fix/silence some svelte-check errors
* Get image-occlusion working with Fabric types
* Post-rebase lock changes
* Editor is now checked
* SvelteKit build integrated into ninja
* Use the new SvelteKit entrypoint for pages like congrats/deck options/etc
* Run eslint once for ts/**; fix some tests
* Fix a bunch of issues introduced when rebasing over latest main
* Run eslint fix
* Fix remaining eslint+pylint issues; tests now all pass
* Fix some issues with a clean build
* Latest bufbuild no longer requires @__PURE__ hack
* Add a few missed dependencies
* Add yarn.bat to fix Windows build
* Fix pages failing to show when ANKI_API_PORT not defined
* Fix svelte-check and vitest on Windows
* Set node path in ./yarn
* Move svelte-kit output to ts/.svelte-kit
Sadly, I couldn't figure out a way to store it in out/ if out/ is
a symlink, as it breaks module resolution when SvelteKit is run.
* Allow HMR inside Anki
* Skip SvelteKit build when HMR is defined
* Fix some post-rebase issues
I should have done a normal merge instead.
* Improve update interval of timer display
Timer calculation frequency increased and aligned with new card apparition.
* Update CONTRIBUTORS
* Update timer interval to 0.333 sec
* Restore timer to 1 sec
- Restoring timer to 1sec value as it is not necessary to increase the frequency.
- Adding a time update directy after new card is displayed so that the timer display immediatly restarts to 0.
This reverts commit 58b2475f42.
Rolling this back for now, as it may cause regressions. We can give it
another try at the start of the next beta-testing period.
* Preserve HTML formatting inside clozes
* Place caret after/inside cloze
To match the old behavior
* Fix clozing in mathjax
* Formatting
* Avoid .extractContents() and handle partially covered tags
* Exclude range end if endOffset == 0
* Remove unnecessary branches
* Use nodeIsElement
* Let extractContents() handle partially selected nodes
* - update remove decks function to return names of all deleted decks
- update protobuf message to display deck names
- update python files to receive message in the frontend.
- add message template to ftl
* update CONTRIBUTORS
* format
* refactor: move up deck names concatenation to tooltip api call
to fix type expectations
* restore core behavior and get deck name from view
* fix type specs
* remove new type and use str instead
restore incorrectly removed lines
* qt/aqt/__init__.py: Skip GL library workaround for FreeBSD
The workaround to load explicitly "libGL.so.1" isn't required for
FreeBSD and leads to segmentation faults if used in environments that
have nVidia drivers loaded.
See also FreeBSD bug 270778 for further details. [1]
[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270778
* Update CONTRIBUTORS
* Update JS deps
* Update semver-compat Rust deps
* Update some semver-incompat Rust deps
- hyper/axum held back because reqwests is not ready
- rusqlite held back due to burn-rs incompat version
- wiremock held back due to compile issue
* pylint wants changes to our _rsbridge.pyi
* Update Python deps
Also solves a security warning in orjson
Reformat with latest black
* fix progress manager close window race condition
* use monotonic clock for time deltas in progress manager
* restructure progress manager finish logic
The progress manager was indicating windows were in a clean state before actually ensuring they were in a clean state. The update to mark things as clean now occurs after cleanup has occurred.
* Add log-in button to preferences screen
* Fix to python to conform to linter
* Add translations for log in/out
* Clean up whitespace/naming
* Move translations from python to qt forms
* Remove sync-not-enabled text on prefs screen
* Add my name to about.py
* Add "sync now?" dialog upon successful login
* Close preferences dialog before syncing
* Yet another Qt 6.6.1 focus fix (dae)
Like 9364dad49a
* adds log module
* enable logging in the app
* adds a getLogger method to AddonManager
* change log level depending on ANKIDEV
* fix undefined module variable
* - fix addons log file path
- remove a breakpoint leftover
set the addons log files under pm.addonFolder()/NNNNNN/user_files/logs/NNNNNN.log
* fix path bug
* move log closing handling into AddonManager deleteAddon/backupUserFiles methods
* logging module level import
fix undefined variable in backupUserFiles
* pretty format log records
* move MediaServer log into logging
* update CONTRIBUTORS
* documentation cleanup
* capture warnings into log messages
fix waitress verbosity
* remove record_factory function
* add get_logger method alias to getLogger in AddonManager
switch to TimedRotatingFileHandler handler
fix minor typo
* set main log level to DEBUG if ANKIDEV is not 0 (or unset)
added two new methods to AddonManager addon_get_logger/addon_toggle_log_level
* add new find_logger_output to AddonManager
* move logs under pm.base
* change log output
* update addonmanager getlogger
* Format imports
* Refactor logging set-up slightly and tweak docstring
* Remove obsolete log closing statements
As logs are no longer stored in user_files, we do not need to close their handlers
* Refactor and try to simplify log module
* Remove demo code
* Refactor and update add-on manager logging API
* Simplify writing unit tests for add-ons that use logging
Loggers are likely to be also employed in non UI code, so it seems like a good idea to decouple them from requiring a running Anki instance to work (thus freeing add-on authors from the need to mock Anki APIs in their tests).
* Fix arguments and drop obsolete inline instructions
Lets add a section on logging to the add-on docs instead
* Drop unnecessary import
* Supply logging basicConfig force option by default
Until we change the module import order and thus ensure that `log` is always evaluated before third-party dependencies have a chance to initialize the root logger, `force` is non-optional.
* Fix formatting and type errors
* Restore mediasrv type ignore comments
* Add note on prefix API stability
* Consistently use addon_from_module in new code
* Use logFolder rather than profileFolder
* Adjust method name for PEP8
* Change loggerDict access path, satisfying pylint
* Drop unused import and use lazy % formatting
* lint fix
* refactor .log_folder -> .addon_logs
store anki.log under logdir
* Fix method name (dae)
* Disable file-based logging in the backend (dae)
I have never found this useful, and it logs nothing by default, so
creating/opening the file is a waste. Removing it also ensures that
addon_logs() is solely used for add-ons.
---------
Co-authored-by: Glutanimate <5459332+glutanimate@users.noreply.github.com>
* Prefer key over keyCode
* Do not close TS pages on Esc when floating elements are open
* Close pop-up when Escape is pressed regardless of keepOnKeyup
* Close help modals when Escape is pressed
* Avoid duplicate handling of Esc in WithFloating
* Formatting
* Handle closing of preset management modals
* Reset text input modal to initial value
* Disable auto advance on review cleanup
* Fix auto advance state resetting on card flip when bottom bar is focused
* Move focus handling to reviewer
* Simplify destruction of previous timers
* Fix auto advance firing early
* Fix handling of 'wait for audio'
* Remove unused import
* When focus is lost, disable auto advance (dae)
Otherwise it will resume when the user answers a card, which is
surprising.
The previous wording could be interpreted as 'time until showing question'
or 'time that question should be shown'. I'd intended the latter, and
I didn't notice that the original implementation was doing the former.
This reverts commit abd8759d50.
Rolling this back for now, as it's caused a couple of regressions:
- In the old path, we returned (html, internal=False); in the new path,
it's returned as internal=True, which prevents formatting from being
stripped. This requires night mode to reproduce, as we don't strip text
colors in day mode.
- It can result in lost alt tags and filenames, as after right clicking on an
image in Chrome and choosing 'copy image', Chrome puts both the HTML and
the image on the clipboard
Related discussion: https://forums.ankiweb.net/t/anki-23-12-beta/37771/90
Message arrived on a background non-Qt thread, and called run_in_background(),
which assumes it's running on the GUI thread. This resulted in single_shot()
failing to run in reviewer's on_av_player_did_end_playing on Linux/macOS.
* Replace css_browser_selector
* Add classes to root element instead of body
* Export addBrowserClasses() in reviewer_extras for mobile clients (dae)
* Avoid setting .mac on iOS devices (dae)