* eslint-plugin-svelte3 -> eslint-plugin-svelte
The former is deprecated, and blocks an update to Svelte 4.
Also drop unused svelte2tsx and types package.
* Drop unused symbols code for now
It may be added back in the future, but for now dropping it will save
200k from our editor bundle.
* Remove sass and caniuse-lite pins
The latter no longer seems to be required. The former was added to
suppress deprecation warnings when compiling the old bootstrap version
we have pinned. Those are hidden by the build tool now (though we really
need to address them at one point: https://github.com/ankitects/anki/issues/1385)
Also removed unused files section.
* Prevent proto compile from looking in node_modules/@types/sass
When deps are updated, tsc aborts because @types/sass is a dummy package
without an index.d.ts file.
* Filter Svelte warnings out of ./run
* Update to latest Bootstrap
This fixes the deprecation warnings we were getting during build:
bootstrap doesn't accept runtime CSS variables being set in Sass, as
it wants to apply transforms to the colors.
Closes#1385
* Start port to Svelte 4
- svelte-check tests have a bunch of failures; ./run works
- Svelte no longer exposes internals, so we can't use create_in_transition
- Also update esbuild and related components like esbuild-svelte
* Fix test failures
Had to add some more a11y warning ignores - have added
https://github.com/ankitects/anki/issues/2564 to address that in the
future.
* Remove some dependency pins
+ Remove sass, we don't need it directly
* Bump remaining JS deps that have a current semver
* Upgrade dprint/license-checker/marked
The new helper method avoids marked printing deprecation warnings to
the console.
Also remove unused lodash/long types, and move lodahs-es to devdeps
* Upgrade eslint and fluent packages
* Update @floating-ui/dom
The only dependencies remaining are currently blocked:
- Jest 29 gives some error about require vs import; may not be worth
investigating if we switch to Deno for the tests
- CodeMirror 6 is a big API change and will need work.
* Roll dprint back to an earlier version
GitHub dropped support for Ubuntu 18 runners, causing dprint's artifacts
to require a glibc version greater than what Anki CI currently has.
Workspace deps were introduced in Rust 1.64. They don't cover all the
cases that Hakari did unfortunately, but they are simpler to maintain,
and they avoid a couple of issues that Hakari had:
- It sometimes made updating dependencies harder due to the locked versions,
so you had to disable Hakari, do the updates, and then re-generate (
e.g. 943dddf28f)
- The current Hakari config was breaking AnkiDroid's build, as it was
stopping a cross-compile from functioning correctly.
Previously it was Backend's responsibility to store the last progress,
and when calling routines in Collection, one had to construct and pass
in a Fn, which wasn't the most ergonomic. This PR adds the last progress
state to the collection, so that the routines no longer need a separate
progress arg, and makes some other tweaks to improve ergonomics.
ThrottlingProgressHandler has been tweaked so that it now stores the
current state, so that callers don't need to store it separately. When
a long-running routine starts, it calls col.new_progress_handler(),
which automatically initializes the data to defaults, and updates the
shared UI state, so we no longer need to manually update the state at
the start of an operation.
The backend shares the Arc<Mutex<>> with the collection, so it can get
at the current state, and so we can update the state when importing a
backup.
Other tweaks:
- The current Incrementor was awkward to use in the media check, which
uses a single incrementing value across multiple method calls, so I've
added a simpler alternative for such cases. The old incrementor method
has been kept, but implemented directly on ThrottlingProgressHandler.
- The full sync code was passing the progress handler in a complicated
way that may once have been required, but no longer is.
- On the Qt side, timers are now stopped before deletion, or they keep
running for a few seconds.
- I left the ChangeTracker using a closure, as it's used for both importing
and syncing.
* Fix .no-reduce-motion missing from graphs spinner, and not being honored
* Begin migration from protobuf.js -> protobuf-es
Motivation:
- Protobuf-es has a nicer API: messages are represented as classes, and
fields which should exist are not marked as nullable.
- As it uses modules, only the proto messages we actually use get included
in our bundle output. Protobuf.js put everything in a namespace, which
prevented tree-shaking, and made it awkward to access inner messages.
- ./run after touching a proto file drops from about 8s to 6s on my machine. The tradeoff
is slower decoding/encoding (#2043), but that was mainly a concern for the
graphs page, and was unblocked by
37151213cd
Approach/notes:
- We generate the new protobuf-es interface in addition to existing
protobuf.js interface, so we can migrate a module at a time, starting
with the graphs module.
- rslib:proto now generates RPC methods for TS in addition to the Python
interface. The input-arg-unrolling behaviour of the Python generation is
not required here, as we declare the input arg as a PlainMessage<T>, which
marks it as requiring all fields to be provided.
- i64 is represented as bigint in protobuf-es. We were using a patch to
protobuf.js to get it to output Javascript numbers instead of long.js
types, but now that our supported browser versions support bigint, it's
probably worth biting the bullet and migrating to bigint use. Our IDs
fit comfortably within MAX_SAFE_INTEGER, but that may not hold for future
fields we add.
- Oneofs are handled differently in protobuf-es, and are going to need
some refactoring.
Other notable changes:
- Added a --mkdir arg to our build runner, so we can create a dir easily
during the build on Windows.
- Simplified the preference handling code, by wrapping the preferences
in an outer store, instead of a separate store for each individual
preference. This means a change to one preference will trigger a redraw
of all components that depend on the preference store, but the redrawing
is cheap after moving the data processing to Rust, and it makes the code
easier to follow.
- Drop async(Reactive).ts in favour of more explicit handling with await
blocks/updating.
- Renamed add_inputs_to_group() -> add_dependency(), and fixed it not adding
dependencies to parent groups. Renamed add() -> add_action() for clarity.
* Remove a couple of unused proto imports
* Migrate card info
* Migrate congrats, image occlusion, and tag editor
+ Fix imports for multi-word proto files.
* Migrate change-notetype
* Migrate deck options
* Bump target to es2020; simplify ts lib list
Have used caniuse.com to confirm Chromium 77, iOS 14.5 and the Chrome
on Android support the full es2017-es2020 features.
* Migrate import-csv
* Migrate i18n and fix missing output types in .js
* Migrate custom scheduling, and remove protobuf.js
To mostly maintain our old API contract, we make use of protobuf-es's
ability to convert to JSON, which follows the same format as protobuf.js
did. It doesn't cover all case: users who were previously changing the
variant of a type will need to update their code, as assigning to a new
variant no longer automatically removes the old one, which will cause an
error when we try to convert back from JSON. But I suspect the large majority
of users are adjusting the current variant rather than creating a new one,
and this saves us having to write proxy wrappers, so it seems like a
reasonable compromise.
One other change I made at the same time was to rename value->kind for
the oneofs in our custom study protos, as 'value' was easily confused
with the 'case/value' output that protobuf-es has.
With protobuf.js codegen removed, touching a proto file and invoking
./run drops from about 8s to 6s.
This closes#2043.
* Allow tree-shaking on protobuf types
* Display backend error messages in our ts alert()
* Make sourcemap generation opt-in for ts-run
Considerably slows down build, and not used most of the time.
* Fix shortcut not being unregistered when Plain/RichTextBadge is detroyed
This fixes an issue where, if the "Show HTML by default" option of
fields located at the same position in two notetypes have different
values, switching between those notetypes during an editor session
would cause the keyboard shortcut (Ctrl+Shift+X) to no longer function
correctly thereafter.
* Don't restore fields' state if notetype has been modified
This fixes an issue where editor fields behave incorrectly after
opening the 'Fields' dialog and customizing the notetype. An example
of incorrect behavior is that after adding a new field and closing
the dialog, the added field would display both richtext input and
plaintext input, regardless of the options.
* Rename type, variable and function
- Apply suggestions from code review
- Also use optional chaining instead of non-null assertion
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.
* 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)
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.
* 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.
* 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
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.
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.
* add grading shortcuts
* add a new setting: grade with space
* new key: u for undo
* run ./ninja format
* rename property
* rename translation
* run ./ninja format
* Fix file extension not being appended on export
Regressed in #2427
* Improve import messaging when notetype has changed
- If the local notes are up to date, we don't need to warn about the
changed notetype, as no updates are required.
- Make it clearer that a changed notetype only affects updates.
Will update the docs as well.
* Allow user to select I/O notetype instead of enforcing a specific name
* Display a clearer error when I/O note is missing an image
Opening the card layout screen from "manage notetypes" was showing an
error about the Anki version being too old.
Replacement error is not currently translatable.
* Preserve existing notetype when adding I/O notetype
* Add a 'from clipboard' string
The intention is to use this in the future to allow an image occlusion
to be created from an image on the clipboard.
* Tweak I/O init
- Use union type instead of multiple nullable values
- Pass the notetype id in to initialization
* Fix image insertion in I/O note
- The regex expected double quotes, and we were using single ones
- Image tags don't need to be closed
* Use more consistent naming in image_occlusion.proto
* Tweaks to default I/O notetype
- Show the header on the front side as well (I presume this is what
users expect; if not am happy to revert)
- Don't show comments on card (again, I presume users expect to use
this field to add notes that aren't displayed during review, as they
can use back extra for that)
* Fix sticky footer missing background
Caused by earlier CSS refactoring
* Store the original stock notetype kind in the notetype
Will allow us to provide a command to restore a notetype to its default
settings/templates.
* Add a new action to restore a notetype to its original state
* Add a deck selector to Stats
* Windows/Linux looks more aligned with 0 top margin
* Prevent Close button from becoming default
If user navigates to deck button with shift+tab, two buttons are highlighted
on Windows/Linux.
* Tweak deck change code
- Remove unneeded initiator argument
- Use our window as the parent, so a progress window will pop up
above the correct window if required.
* add note types with occlusions and image fields
* generate image occlusion cloze div data
- generate div element with data-* atrributes for canvas shape generate for reviewer
* getting image data & deck id and adding notes
the implementation added into backend
- added service index in backend.proto for image occlusion request
- created image_occlusion.proto with required message and service
- implementation in backend for getting image and adding notes, also during editing return imagecloze note and update notes
- add notes to selected deck, if no notetype then add image occlusion notetypes
- reuse notetype from stock notetypes when not exist
* script for generating shapes using canvas api in reviewer
- the flash issues fixed by loading image and using image size to draw canvas, also when image get resized, calculate scale using natural width and canvas width to draw shape at right position
- limit size of canvas for safari
* init image occlusion page in ts and build page
with
- fabricjs for editing shapes
- panzoom for drag and zoom
- pickr for color picker
- build page using web.rs
* implement top toolbar for canvas shapes
- undo & redo tools
- zoom in, zoom out and zoom fit
- group & ungroup
- copy & paste
- set transparency of shapes
- align tools
* implement side toolbar for drawing shapes
add top toolbar and the side toolbar contains following tools
- cursor for selecting shapes
- zoom for drag and zoom shapes in mask editor
- rectangle for creating it
- ellipse for creating it
- polygon for creating it using points
- shape fill color
- question mask color (currently only single color can be added for all shapes)
* add maskeditor page for editing mask
- add side toolbar and sidebar include toptoolbar
- load maskeditor in two mode
- for adding note using path to image
- for editing note using note id
* implement note editor page for adding notes
- the note editor page have simple button (B/I/U) and option to toggle html view
- option to select deck for adding notes into that deck
- option to generate to hide all, guess one & hide one, guess one notes
* add image occlusion page
add side toolbar, top toolbar, mask editor and note editor
- option to switch between mask editor and note editor
* implement generates notes and save notes
implemention to show toast components for messages
* removed pickr & implemented color picker component
- remove pickr
- implemented using html5 canvas
- range input for changing color
- another range input for opacity changes
- hex and rgba value support
* rename methods name & rust unwrap safety
- change plural names to singular
- create respone message in proto and return response with imagecloze note or error if not found with note id
- remove image_occlusion from post handler list
- rename service name in mediasrv.py
- rename methods name for image occlusion in backend and image_occlusion
- update frontend also for update functions' names
- handle error in frontend mask-editor.ts, when error getting notes then toast message shown to frontend
* extract to function & add comments & remove global
- extract function in mask-editor.ts to reduce duplicate
- remove unused global from css
- add comments to store.ts explaining usage
- changes id to noteId in lib.ts
- add comments for limitSize, becuase of duplicate implementation
* remove image_occlusion notetype
- remove from stock notetype, stdmodels
- add implementation for notetype to image occlusion
- add i18n for errors
* update smooth scroll, always show cursor tools
- change questionmask to qmask
- make selectable for shape true in all tools to simplify edits and draw shapes
- update image occlusion in reviewer ts to load image properly
* add and get notetype else return errors
* fix: not showing occlusion
* Use a oneof for ImageClozeNoteResponse
Makes it clearer that only one of them can be returned
* Don't crash if image filename not provided
The second unwrap should be ok, as the input is utf8
* Refactor get_image_cloze_note
- fixes crash when note doesn't exist - Ok(None) case was not covered
- decouples business logic from native error->proto error conversion
- no need for original copy
- field[x] is more idiomatic than field.get(x).unwrap()
- don't need mutable access to fields
* Fix crash if image file unreadable
+ Use our read_file helper for better error context
* Add metadata() helper
* Fix crash if file metadata can't be read
* remove color picker, qmask and shape color
- remove strings from ftl
- remove color picker component
- remove from cloze generation
- remove icons for two buttons
- use constant color for shapes
* update color in reviewer and ftl strings
* fix shape position in canvas & add border to shape
- rename mask to inactive shape and active shape color
- border witdth and border color
- change decimal point deserializing string and toFixed(2)
- add thin border in mask editor, may be image background was transparent
* fix shape position in canvas after modified
- do not draw fixed ratio shapes by turn of uniformScaling
- fix rectangle width,height
- fix ellipse rx,ry,width,height
- fix polygon postion and points
- draw outside of canvas also
* fix border width and color in reviewer canvas
- rename variable
* refactor cloze div generate and remove angle
* fix origin when drawn outside of canvas from right
* fix shape at boundry & not include rx,ry rectangle
- move shapes at boundry when pointer is outside of canvas
- include rx, ry for ellipse only
- include points for polygon only
* fix lint errors & update image size in editor canvas based on height and width
* remove unsupported layerX & layerX for touchscreen
- fix shapes at edges
* implemented undo redo with canvas state
- implemented undo redo using fabric canvas events
- polygon is special case and implemented only added and modified event
- rectangle and ellipse have object:added, object:modified and object:removed case
- change id to undo and redo
* remove background image from canvas and used css to put image tag below canvas editor
- set image width and height after adding image
* fix for polygon points, add br in cloze strings, & toogle masks button
- fix shapes at edges
- toggle masks button to show/hide masks
- hide clozes string, it contains <br>
- set height for div container (used 'relative' in css)
* refactor top toolbar, add space and border radius
- rename cursor tools
- add left and right border
* fix undo after undo happen, use transparent color in draw mode
* bump walkdir from 2.3.2 to 2.3.3
Build was failing on windows due to walkdir matching . as any folder starting with . instead of as the cwd.
* change name in CONTRIBUTORS
* change name back in CONTRIBUTORS
* fix stats calendar daylight saving time offset bug
Previously, when computing counts for the calendar in the stats menu, it was assumed that days had 86,400 seconds. However, this assumption does not hold true on the day when daylight savings occurs.
* add self to CONTRIBUTORS and about.py
* fix stats calendar anki day to calendar day mapping
Since Anki days don't necessarily roll over at midnight, mapping an Anki day into a calendar day needs to have a linear shift applied. By providing the frontend with access to the scheduler's rollover hour, we can account for this offset.
* Add option to exclude fields from unqualified searches
* Use temp tables instead
This is slightly faster according to my (very rough) tests.
* Make query a bit more readable
* exclude_from_search -> excludeFromSearch
* Remove superfluous notetypes table from query
* Rework to use field search logic
Thanks to Rumo for the suggestion: https://github.com/ankitects/anki/pull/2394#issuecomment-1446702402
* Exclude fields from field searches too
* Fix error on notetypes with no included fields
* Add back the exclude_fields function
This approach seems to perform better on average than the previously
benchmarked ones.
* Use pure-SQL approach to excluding fields
* Change single field search to use new approach
* Fix flawed any_excluded/sortf_excluded logic
* Support field exclusion in the nc operator
Also fix search text being wrapped in % in the any_excluded=true case.
* Support field exclusion in the re and w operators
* Label field exclusion as being slower
* Unqualified search should be wrapped in % in all cases
I was under the impression that it shouldn't be wrapped with the new
field exclusion logic.
* Remove unnecessary .collect()
* Refactor some complex return types into structs
* Do not exclude fields in field searches
* Add a test and docstring for CollectRanges
* Avoid destructuring in closures
* Remove the exclude_fields function
Minor wording tweaks by dae:
* num_fields -> total_fields_in_note
* fields -> field_ranges_to_search
* fields -> fields_to_search
* SingleField -> FieldQualified
* mid -> ntid
* Ensure state mutator runs after card is rendered
* Ensure ease buttons only show when states are ready
* Pass context into states mutator
* Revert queuing of state mutator hook
Now that context data is exposed users shouldn't rely on the question
having been rendered anymore.
* Use callbacks instead of signals and timeout
... to track whether the states mutator ran or failed.
* Make mutator async
* Remove State enum
* Reduce requests and compute seed on backend
* List actions and locals in debug console
* Ignore whitespace when wrapping line with pp
* Scroll down after printing in debug console
Was previously preserving relative vertical position.
* Add feature to open and save debug scripts
* Refactor debug console into own module
* Add buffers to switch scripts
* Add action to delete script
* Revert "Fix open editors getting carried over to different notetypes (#2393)"
This reverts commit bf5bcd3f52.
* Improved fix for open editors getting carried over to different notetypes
* Run ninja format
Flask's .send_file() method sends a content-disposition header based
on the filename. If the filename includes non-Latin text, it adds an
rfc5987 unicode filename, but does not percent-escape the commas.
This causes Chromium to fail to load the image with the following
error:
net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
curl -v http://127.0.0.1:40000/Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png
* Trying 127.0.0.1:40000...
* Connected to 127.0.0.1 (127.0.0.1) port 40000 (#0)
> GET /Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png HTTP/1.1
> Host: 127.0.0.1:40000
> User-Agent: curl/7.86.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: public, max-age=3600
< Content-Disposition: inline; filename="Captura de ecra 2023-02-26, as 18.33.03.png"; filename*=UTF-8''Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png
Fixed by supplying a dummy filename.
When a user clicks on the table row in the deck list (neither click on the deck
link nor on the options menu) while the shift key is pressed,
then set the deck in that table row as the current deck.
This gives the user some quick feedback and enables the user to easily create
subdecks (as it automatically fills the add deck dialog with the deck name of
the selected deck) and to create notes belonging to the selected deck.
* Remove Pane components and use Collapsible for TagEditor
* Update translations
* Give TagEditor border and focus outline
* Use ScrollArea from #2248 for fields
* Refactor ScrollArea
* Fix error caused by calling bridgeCommand when it's not available
* Make sure tag editor fills whole width of container
which is important for the CSV import page.
* Update NoteEditor.svelte
* Add back removed ftl strings
* Fix tests (dae)
* Implement TTS using windows crate
* Use API calls instead of SSML
* Properly stop player in case of TTS error
* Add context to WindowsErrors
* Validate available voices
* Remove TTS text from synthesize error
* Limit maximum buffer size
* Make validation optional and list it in tts filter
* We no longer need the winrt module (dae)
* Use a separate request object so the meaning of the bool is clear (dae)
* Slightly shorten runtime error message (dae)
The default message appears to clip slightly.
* Alternate buffer implementation (dae)
* Use array instead of vec
* Drop the max buffer size to 128k (dae)
* Replaced ankimedia object directly call by addon specific hook
# Conflicts:
# qt/aqt/browser/previewer.py
# qt/aqt/clayout.py
# qt/aqt/reviewer.py
* Replaced ankimedia.js by addon specific hook
# Conflicts:
# qt/aqt/browser/previewer.py
# qt/aqt/clayout.py
# qt/aqt/main.py
* Create specific location name for each hook to reuse control
* Created the card_review_webview_did_init hook
* Extended the hook card_will_show to replace will_show_web
The new hook card_will_show_state takes three new arguments
* Created the hook audio_did_pause_or_unpause to replace will_show_web
The new hook is called when audio toggle pause is called
* Created the hook audio_will_replay to replace will_show_web
The new hook is called when the audio is replayed by the user.
* Created the hook previewer_will_redraw_after_show_both_sides_toggled
to replace will_show_web.
The new hook fully replaces the last uses of will_show_web.
* Replaced card_will_show_state hook with reviewer_did_init and
equivalents. Instead of receiving the required state, it access it
by caching the object values with hooks as reviewer_did_init.
* Create common web view registry and unify title setting
* Consistently use space-separated naming for webview titles
None of the modified titles seem to be in use by add-ons, so we are not bound to the current naming.
The old naming was likely following camelCase as the name was also acting as a key for saveGeom, which is no longer the case.
* Update webview_did_inject_style_into_page example
* Add docstring to addon-targeted method
* Change AnkiWebView.origin to property
* Fix dupe enum value
* Tweak method name
* Add semicolon
* Rename `AnkiWebViewOrigin` to `AnkiWebViewKind`
* Allow burying cards in browser
This code is based on existing "toggle suspend" command in browser.
- Adds "toggle bury" command to browser cards menu.
- Adds "browsing-toggle-bury" to core translation. Only english-language.
- Adds "buried" coloring to rows for buried cards in browser table.
Not yet done:
- Keyboard shortcut for "toggle bury" action.
- Non-english translations.
* Add contributor as requested in CONTRIBUTORS.
* Fix formatting in browser_table.rs.
* Add keyboard shortcut to "toggle bury" command.
This adds keyboard shortcut "ctrl-shift-j" to "toggle bury" command in
browser cards menu.
* Simplify logic for color of buried-card rows.
On Linux distributions that do not yet support org.freedesktop.appearance.color-scheme (most distros released prior to 2022), querying DBus for the missing property produces verbose journal entries over Anki's entire runtime.
* Create widget gallery dialog
* Add WidgetGallery to debug dialog
* Use enum for its intended purpose
* Rename "reduced-motion" to "reduce-motion"
* Add another border-radius value
and make former large radius a bit smaller.
* Revamp preferences, add minimalist mode
Also:
- create additional and missing widget styles and tweak existing ones
- use single profile entry to set widget styles and reduce choices to Anki and Native
* Indent QTabBar style definitions
* Add missing styles for QPushButton states
* Fix QTableView background
* Remove unused layout from Preferences
* Fix QTabView focused tab style
* Highlight QCheckBox and QRadioButton when focused
* Fix toolbar styles
* Reorder preferences
* Add setting to hide bottom toolbar
* Move toolbar settings above minimalist modes
* Remove unused lines
* Implement proper full-screen mode
* Sort imports
* Tweak deck overview appearance in minimalist mode
* Undo TitledContainer changes
since nobody asked for that
* Remove dynamic toolbar background from minimalist mode
* Tweak buttons in minimalist mode
* Fix some issues
* Reduce theme check interval to 5s on Linux
* Increase hide timer interval to 2s
* Collapse toolbars with slight delay when moving to review state
This should ensure the bottom toolbar collapses too.
* Allow users to make hiding exclusive to full screen
* Rename full screen option
* Fix hide mode dropdown ignoring checkbox state on startup
* Fix typing issue
* Refine background image handling
Giving the toolbar body the main webview height ensures background-size: cover behaves exactly the same.
To prevent an override of other background properties, users are advised to only set background-images via the background-image property, not the background shorthand.
* Fix top toolbar getting huge when switching modes
The issue was caused by the min-height hack to align the background images. A call to web.adjustHeightToFit would set the toolbar to the same height as the main webview, as the function makes use of document.offsetHeight.
* Prevent scrollbar from appearing on bottom toolbar resize
* Cleanup
* Put review tab before editing; fix some tab orders
* Rename 'network' to 'syncing'
* Fix bottom toolbar disappearing on UI > 100
* Improve Preferences layout by adding vertical spacers to the bottom
also make the hiding of video_driver and its label more obvious in preferences.py.
* Fix bottom toolbar animating on startup
Also fix bottom toolbar not appearing when unchecking hide mode in reviewer.
* Hide/Show menubar in fullscreen mode along with toolbar
* Attempt to fix broken native theme on macOS
* Format
* Improve native theme on other systems by not forcing palette
with the caveat that theme switching can get weird.
* Fix theme switching in native style
* Remove redundant condition
* Add back check for Qt5 to prevent theme issues
* Add check for macOS before setting fusion theme
* Do not force scrollbar styles on macOS
* Remove all of that crazy theme logic
* Use canvas instead of button-bg for ColorRole.Button
* Make sure Anki style is always based on Fusion
otherwise we can't guarantee the same look on all systems.
* Explicitly apply default style when Anki style is not selected
This should fix the style not switching back after it was selected.
* Remove reduncant default_palette
* Revert 8af4c1cc2
On Mac with native theme, both Qt5 and Qt6 look correct already. On
the Anki theme, without this change, we get the fusion-style scrollbars
instead of the rounded ones.
* Rename AnkiStyles enum to WidgetStyle
* Fix theme switching shades on same theme
* Format
* Remove unused placeholderText
that caused an error when opening the widget gallery on Qt5.
* Check for full screen windowState using bitwise operator
to prevent error in Qt5.
Credit: https://stackoverflow.com/a/65425151
* Hide style option on Windows
also exclude native option from dropdown just in case.
* Format
* Minor naming tweak
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.
* 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
* 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)
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.
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.
* Use a webview to show add-on's config help
This allows add-ons to embed images for example.
* Improve initial size of splitter widgets
* Decrease font size and margin of webview
* Run cargo +nightly fmt
* Latest prost-build includes clippy workaround
* Tweak Rust protobuf imports
- Avoid use of stringify!(), as JetBrains editors get confused by it
- Stop merging all protobuf symbols into a single namespace
* Remove some unnecessary qualifications
Found via IntelliJ lint
* Migrate some asserts to assert_eq/ne
* Remove mention of node_modules exclusion
This no longer seems to be necessary after migrating away from Bazel,
and excluding it means TS/Svelte files can't be edited properly.
This reverts commit 5dc79e22cd.
I appear to have been confused in my earlier testing, as reverting
this change seems to make no difference the top bar on first startup,
and fixes a bunch of other regressions that the original change introduced.
https://github.com/ankitects/anki/issues/2269
* Swap flag and mark indicator position in RTL mode
* Make buttons of bottom toolbar align to edge of screen in RTL mode
* Use start instead of left and end instead of right
Ensures the background is the correct color by the time the webview
is shown. We keep the #night check for now, as it's useful when testing
in an external browser.
The starting size of a webview seems to be 640x480, but if it is hidden
without retainSizeWhenHidden being set, the dialog it contains can end
up with a height of 0, which prevents the dialog from being shown.
By being explicit about our desired starting size, we can use a more
useful default, and avoid the issue of missing dialogs.
* Facilitate updating of hooks
- Add instructions in contributing.md
- Change addon_config_editor_will_update_json hook to work with the new
hookslib code
* Fix typo in docs
* Always run replaced hook
* Use lowercase list for typing
* Forbid defining both a replaced and a legacy hook
* Persist collapsed- and field states with SessionOptions object
* Format types.ts
* Replace format function with f-string
* Give setters more descriptive parameter names
* Do not use default prefix for descriptions and fonts
since they are not meant to be changed via Svelte.
When opening the graphs screen in dark mode, we want to load the
page first and then reveal the webview, to prevent a flash of white
that can appear as the page loads. Previously we did this for any
call to load_ts_page(), but this results in flicker when refreshing
an existing webview, such as the move from deck list to congrats screen.
In those cases, at least on the machines I have to test with here, the
refresh is smoother without the hide and show step.
The new window case is still not ideal - while the hide+show prevents a
flash of white, there is a flash of black instead, presumably as the
webview draws the initially-blank framebuffer with the contents of the
webview.
* Fix QMenu item not having different color on hover
due to the color changes in #2220.
* Remove strong border on pressed Qt widgets
* Make button gradient more subtle
by changing gradient-start on hover instead of gradient-end.
* Apply QPushButton style to QSpinBox buttons
* Improve margin of QComboBox arrow
* Make button-bg same color as button-gradient-end
This makes the hover gradient more subtle.
This reverts commit fa4fc3e15a.
Issue turned out to be a packaging problem, and this should not be
required as the socket should be held open even if removed.
This reverts commit ee70006ec4.
There have been a number of people complaining that the current
behaviour is not intuitive, and they have a point - it's not the
way browsers behave when you navigate between pages.
I was able to reproduce the crashes fairly reliably by opening the
prefs screen on startup and shutting down the app after 600ms; after
this change the crashes no longer seem to occur.
* 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
(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
* 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.
* Center table headers
by giving the arrow a negative margin equal to its width.
* Prevent overlap with arrow for small headers (largely)
I didn't want to go all out and make the right padding equal to the width of the arrow, because it would cut off the text too early on sections that aren't active.
* Hide vertical table header on Windows too
* Remove margin between toolbars in main view
Didn't want to create a separate PR for such a minor change.
* Create better borders for QTableWidget
* Remove unused import
* Improve RTL appearance of table
* Use button gradient only on hover
* Apply hover effect to main window buttons
* Apply arbitrary change to force recreation of colors.py
* Undo arbitrary change to fix props not being created
* Remember that the comments are used for regex matching
* Yet another try
* Revert "Yet another try"
This reverts commit eaef4805c1618cf93ac2f93bc14ada900dc6d155.
* Update _root-vars.scss
Otherwise when user returns to profiles screen, they'll be unable to
open a different profile, as the collection is still open.
Encountered when opening the collection that triggered
https://github.com/ankitects/anki/issues/2123
* Prevent multiple inclusion of variables in CSS files
* Use dict instead of tuple for variables
* Add comments to variables
* Improve appearance of main window
* Tweak main window styles
* Use json.dumps over pprint.format
* Make study button primary
* Improve header margin
* Make bottom toolbar slimmer
* Make congrats page more balanced
* Fix type issue
* Replace day/night with light/dark
* Exclude top-level-drag-row from hover effect
* Create dataclass for variables
* Run formatter
* Apply CSS variables from Python side
Why go full-circle with the Sass variables? This way we only need one interface for add-on authors to interact with. It also makes it easier for us to apply additional themes in the future.
* Fix typing
* Fix rgba values in Qt
* Darken button background
* Fix palette not being applied in light theme
For some odd reason this problem arose much later than #2016.
* Tweak default button look
* Reformat
* Apply CSS vars to ts pages
* Include elevation in button_mixins_lib
* Cast opacity to int
* Add some margin to studiedToday info
* Tweak light theme button gradient
* Tweak highlight-bg for light theme
* Add back default button color
as it made the browser sidebar tool icons dark in light theme.
* Reformat
* Tweak light theme buttons once more
Sorry for the back-and-forth. Sass only compiles when there are changes in user files, not when I only change the vars.
* Fix bottom toolbar button indicators
* Make buttons more clicky
* Fix button padding
* Handle macOS separately again
* Decrease elevation effect for main window buttons to 1
* Imitate box-shadow for Qt elements
* Adjust shadow vars
* Adjust primary border color
because the save button in the deck options had a lighter color than its background gradient.
* Boost box-shadow color of primary buttons
* Format
* Adjust Qt box-shadow imitation and shadow colors
* Use more subtle default shadow color
* Add some more padding to top toolbar
* Revert "Apply CSS vars to ts pages"
This reverts commit 5d8e7f6b7ffc8894b6517ecbb8cfba35407fc69a.
* Revert "Apply CSS variables from Python side"
This reverts commit 87db774412fd2bfd75e2630d2c5e782daef96b5f.
* Better match the standard macOS buttons
In the dark theme the standard color is a lighter grey, but at least
the size/shape is similar again.
This doesn't work for the editor buttons.
* Reduce the top margin of the congrats screen
* Fix illegible buttons when changing theme on macOS; match dark button style
Pylint is no longer able to detect available members in the generated
protobuf files, so we need to exclude them from processing. This should
not be a problem as we get these checks from mypy already, and as a
bonus we no longer need to exclude protobuf classes manually.
The fact that anki.sync_pb2 needs to be added after the wildcard appears
to be a bug.