Commit Graph

9280 Commits

Author SHA1 Message Date
Henrik Giesel
202207b765
Update prettier-plugin-svelte (#1711) 2022-03-05 14:27:47 +10:00
RumovZ
5426164ebf
Add regex tag search (#1707) 2022-03-04 18:43:27 +10:00
Damien Elmes
4066518808 Clean up webview after fields dialog closed
https://github.com/ankitects/anki/pull/1706#issuecomment-1058056161
2022-03-04 17:23:28 +10:00
Henrik Giesel
76bdfb3899
Add a flag to allow loading the fields dialog in a web view (#1706)
* Load fields_web from fields.py if appropriate flag is set

* Add FieldsPage as entry for new fields view

* Pass mypy

* Fix pylint

* Fix fields_web in Qt5 (dae)

May not be related to the CI error, but required for compatibility
with Qt5.
2022-03-03 22:45:26 +10:00
Damien Elmes
a06036b8aa Disable buried counts on overview when v2 scheduler in use
https://forums.ankiweb.net/t/fatal-bug-anki-2-1-50-beta5-buried-bug/17969
2022-03-03 20:12:54 +10:00
Damien Elmes
2c80bcb571 Update to latest rules_rust, which unblocks the tokio upgrade
Rust version has been pinned, as 1.59 gets stuck compiling pyo3_macros,
and appears to have other issues:
https://github.com/rust-lang/rust/issues/94390
2022-03-03 19:48:17 +10:00
Henrik Giesel
29d17a84fc
Fix newline shortcut in MathjaxMenu (#1705) 2022-03-03 18:55:07 +10:00
RumovZ
508b5ab947
Remove top_deck_id arg in deck_tree() (#1702)
Counts don't propogate correctly anymore (#1678).
2022-03-02 15:30:32 +10:00
Henrik Giesel
88217c5e7d
Replace (some) Bootstrap dropdowns with Floating UI (#1695)
* Implement a first version of WithFloating and Portal

* Add outside slot for Portal

* Execute computePosition from WithFloating

* Set up a first example of new WithFloating with the Latex menu

* Use autoUpdate in WithFloating

* Create sveltelib/position

* Add event-store

* Use event-store in close-on-click

* Implement subscribeToUpdates

* Introduce sass/elevation

* Split close-on-click to closing-click and subscribe-trigger

* Have closing-* stores return a symbol

- This way they act more of an EventEmitter than a store

* Allow passing show store

* Remove styling on float on updatePosition removal

* Implement a nice border for dropdowns

* Apply different border and box-shadow to Popover in dark/light theme

* Fix Ctrl+Shift+T not working

* Satisfy formatters and tests

* Add copyright header

* move copyright header to top (dae)
2022-03-02 14:21:19 +10:00
PatricCunhaforWork
1219dd8f9e
Add silent option for uninstaller (#1690)
* Add /S option for unattended uninstall

* Add email to contributors
2022-03-02 13:55:57 +10:00
Damien Elmes
6ae24652e5 Fix add-on config screen failing to show in bundled build
md_in_html imports fine when done manually; it is likely PyOxidizer
has not instrumented import_module().

  File "aqt.addons", line 631, in addonConfigHelp
  File "markdown.core", line 386, in markdown
  File "markdown.core", line 96, in __init__
  File "markdown.core", line 123, in registerExtensions
  File "markdown.core", line 162, in build_extension
  File "importlib", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'md_in_html'
2022-02-28 20:49:35 +10:00
Henrik Giesel
92bf23df99
Use async functions in .svelte files (#1693)
* Use async functions in CodeMirror.svelte

* Fix using async functions by modifying svelte-preprocess output

* Revert "Fix using async functions by modifying svelte-preprocess output"

This reverts commit 94c9cadaaa3ca2084780833e9efc7807f2f1d1a9.

Trying a different fix.

* Change TypeScript target to ES2019
2022-02-27 22:35:47 +10:00
Damien Elmes
6941bccde4 Add support for proto3 optional scalars
Protobuf 3.15 introduced support for marking scalar fields like
uint32 as optional, and all of our tooling appears to support it
now. This allows us to use simple optional/null checks in our Rust/
TypeScript code, without having to resort to an inner message.

I had to apply a minor patch to protobufjs to get this working with
the json-module output; this has also been submitted upstream:
https://github.com/protobufjs/protobuf.js/pull/1693

I've modified CardStatsResponse as an example of the new syntax.

One thing to note: while the Rust and TypeScript bindings use optional/
null fields, as that is the norm in those languages, Google's Python
bindings are not very Pythonic. Referencing an optional field that is
missing will yield the default value, and a separate HasField() call
is required, eg:

```
>>> from anki.stats_pb2 import CardStatsResponse as R
... msg = R.FromString(b"")
... print(msg.first_review)
... print(msg.HasField("first_review"))
0
False
```
2022-02-27 19:42:06 +10:00
Henrik Giesel
55c64e5b54
Fix Mathjax sometimes being deleted even though it's not selected (#1696)
* Fix frame element being deleted, when a frame handle is deleted from while selected

* Fix mixing up preceding/following
2022-02-27 17:58:01 +10:00
Henrik Giesel
5963791d85
Consider using --force-message for ts/protobuf.bzl (#1694)
* Use --force-message in ts/protobuf

* Remove some now unnecessary type assertions in deck-options/lib

* Satisfy formatter
2022-02-27 17:35:07 +10:00
Damien Elmes
3564ece6b5 Update translations 2022-02-25 17:24:53 +10:00
Damien Elmes
91cc311f74 Tweak ftl:sync paths 2022-02-25 17:24:52 +10:00
Damien Elmes
89bce6d829 Update Rust deps; pin Tokio
Tokio has had to be pinned, because the 1.17 release introduces
a dependency on windows_sys, which fails to build on Windows on
Bazel.

The issue appears to be the build script of a subcrate - it is using
CARGO_MANIFEST_DIR to update the linking path so windows.lib can be
found (it's contained in that crate), but the path is set incorrectly.

dfc25285a2/crates/targets/x86_64_msvc/build.rs

One way we might be able to work around it is to add to the link path
in our own build script.
2022-02-25 17:10:47 +10:00
Damien Elmes
625d8596a4 Update to Jest 28 alpha
https://github.com/ankitects/anki/pull/1682
2022-02-25 16:20:50 +10:00
Damien Elmes
902f125954 Update rules_nodejs 2022-02-25 16:19:26 +10:00
Damien Elmes
f3b0c31354 Update JS deps 2022-02-25 15:29:49 +10:00
Damien Elmes
1165939271 Update Python deps, including stable Black
Black 22.1 made some changes that required some minor reformatting.
2022-02-25 15:26:16 +10:00
Damien Elmes
d52c36e920 Make flag changes undoable again
The previous change in 1871b57663 failed
to consider the browser refreshing case, as reported here:
https://forums.ankiweb.net/t/anki-2-1-50-beta-3-4/17501/30

I previously attempted to solve this by having SetFlag skip the queue
rebuild, then mutating the captured mtimes in the queues. That didn't
work correctly when undoing, as the queue mutations weren't recorded.
This approach combines that attempt and the previous change: flag
setting is an undoable operation again, but does not change the card's
modification time, so it can be applied/undone without a queue build
being required. Instead of special-casing flag changes in the review
screen, we now just redraw the flag on changes.card, as any other card
op will have triggered a queue rebuild.
2022-02-25 15:06:07 +10:00
Damien Elmes
776631bbf5 Automatically clean up stale files on TS build error 2022-02-25 12:25:55 +10:00
Henrik Giesel
50e36bc312
Fix plain text (#1689)
* Move remove-prohibited-tags logic from PlainTextInput

* Make CodeMirror export a promise

* Offer lifecycle hooks for PlainTextInput for easily accessing code mirror instance

* Fix </> breaking Mathjax

* remove debug statement (dae)
2022-02-25 11:14:26 +10:00
Henrik Giesel
7c27159149
Fix setting of caret when creating clozes (#1688) 2022-02-25 11:07:44 +10:00
Henrik Giesel
0d83581ab0
Fix insert media always insert at the start (on Windows) (#1684)
* Move Trigger into its own file

* Try implement HandlerList

* Implement new input handler and handler-list

* Use new refocus HandlerList in TextColorButton

* Fix TextColorButton on windows

* Move ColorPicker to editor-toolbar

* Change trigger behavior of overwriteSurround

* Fix mathjax-overlay flushCaret

* Insert image via bridgeCommand return value

* Fix invoking color picker with F8

* Have remove format work even when collapsed

* Satisfy formatter

* Insert media via callback resolved from python

* Replace print with web.eval

* Fix python formatting

* remove unused function (dae)
2022-02-25 10:59:06 +10:00
RumovZ
a0d0f2f8fd
Add progress.single_shot() (#1683)
* Add progress.single_shot()

* Fix periodic garbage collection

* Properly cleanup mediasync timers

* Revert some replacements with `single_shot()`

These timers shouldn't fire if their widget is destroyed.

* Add timer docs explaining issues and alternatives

* Apply suggestions from code review

* Tweak docstrings
2022-02-24 21:15:56 +10:00
sachingooo
5eefb9bea7
Match deck name truncation behavior to prevent long deck names from obscuring stats (#1686)
* Truncate long deck names to match AnkiWeb behavior

Prevent long deck name from obscuring deck stats in main deck browser - match behavior at https://ankiweb.net/decks/ for handling long deck names (truncate name)

* Fix formatting

* Update CONTRIBUTORS

Add myself to contributors list
2022-02-24 10:15:26 +10:00
Damien Elmes
1a3eef505f interday sibling burying is only valid in v3 2022-02-23 14:33:52 +10:00
Damien Elmes
4ed499fbab fix bundle_extras_linux_amd64 link 2022-02-22 23:42:21 +10:00
Damien Elmes
256421ca3e remove zoom in/out shortcuts
https://github.com/ankitects/anki/pull/1668#issuecomment-1044058021
2022-02-22 23:12:21 +10:00
RumovZ
a4d61fe7d9
Original position (#1677)
* Replace Card.data with .original_position

* Use and update original position in v3

* Show original position in card info

* Revert restoring original position for now

* Fix pb card to/from pylib card

* Try original_position as the last pb field

* minor wording tweaks (dae)
2022-02-22 22:48:21 +10:00
Henrik Giesel
8b84368e3a
Move all buttons to our custom inline surrounding (#1682)
* Clarify some comments

* Don't destructure insertion trigger

* Make superscript and subscript use domlib/surround

* Create new {Text,Highlight}ColorButton

* Use domlib/surround for textcolor

- However there's still a crucial bug, when you're breaking existing
  colored span when unsurrounding, their color is not restored

* Add underline format to removeFormats

* Simplify type of ElementMatcher and ElementClearer for end users

* Add some comments for normalize-insertion-ranges

* Split normalize-insertion-ranges into remove-adjacent and remove-within

* Factor out find-remove from unsurround.ts

* Rename merge-mach, simplify remove-within

* Clarify some comments

* Refactor first reduce

* Refactor reduceRight

* Flatten functions in merge-ranges

* Move some functionality to merge-ranges and do not export

* Refactor merge-ranges

* Remove createInitialMergeMatch

* Finish refactoring of merge-ranges

* Refactor merge-ranges to minimal-ranges and add some unit testing

* Move more logic into text-node

* Remove most most of the logic from remove-adjacent

- remove-adjacent is still part of the "merging" logic, as it increases
  the scope of the child node ranges

* Add some tests for edge cases

* Merge remove-adjacent logic into minimal-ranges

* Refactor unnecessary list destructuring

* Add some TODOs

* Put removing nodes and adding new nodes into sequence

* Refactor MatchResult to MatchType and return clear from matcher

* Inline surround/helpers

* Shorten name of param

* Add another edge case test

* Add an example where commonAncestorContainer != normalization level

* Fix bug in find-adjacent when find more than one nested nodes

* Allow comments for Along type

* Simplify find-adjacent by removing intermediate and/or curried functions

* Remove extend-adjacent

* Add more tests when find-adjacent finds by descension

* Fix find-adjacent descending into block-level elements

* Add clarifying comment to refusing to descend into block-level elements

* Move shifting logic into find-adjacent

* Rename file matcher to match-type

* Give a first implemention of TreeVertex

* Remove MatchType.ALONG

- findAdjacent now directly modifies the range

* Rename MatchType.MATCH into MatchType.REMOVE

* Implement a version of find-within that utilizies match-tree

* Turn child node range into a class

* Fix bug in new find-adjacent function

* Make all find-adjacent tests test for ranges

* Surrounding within farthestMatchingAncestor when available

* Fix an issue with negligable elements

- also rename "along" elements to "negligable"

* Add two TODOs to SurroundFormat interface

* Have a messy first implementation of the new tree-node algorithm

* Maintain whether formatting nodes are covered or within user selection

* Move covered and insideRange into TreeNode superclass

* Reimplement findAdjacent logic

* Add extension logic

* Add an evaluate method to nodes

* Introduce BlockNode

* Add a first evaluate implementation

* Add left shift and inner shift logic

* Implement SurroundFormatUser

* Allow pass in formatter, ascender and merger from outside

* Fix insideRange and covered switch-up

* Fix MatchNode.prototype.isAscendable

* Fix another switch-up of covered and insideRange...

* Remove a lot of old code

* Have surround functions only return the range

- I still cannot think of a good reason why we should return addedNodes
  and removedNodes, except for testing.

* Create formatting-tree directory

* Create build-tree directory + Move find-above up to /domlib

* Remove range-anchors

* Move unsurround logic into no-splitting

* Fix extend-merge

* Fix inner shift being eroneusly returned as left shift

* Fix oversight in SplitRange

* Redefine how ranges are recreated

* Rename covered to insideMatch and put as fourth parameter instead of third

* Keep track of match holes and match leaves

* Rename ChildNodeRange to FlatRange

* Change signature of matcher

* Fix bug in extend-merge

* Improve Match class

* Utilize cache in TextColorButton

* Implement getBaseSurrounder for TextColorButton

* Add matchAncestors field to FormattingNode

* Introduce matchAncestors and getCache

* Do clearing during parsing already

- This way, you know whether elements will be removed before getting to
  Formatting nodes

* Make HighlightColorButton use our surround mechanism

* Fix a bug with calling .removeAttribute and .hasAttribute

* Add side button to RemoveFormat button

* Add disabled to remove format side button

* Expose remove formats on RemoveFormat button

* Reinvent editor/surround as Surrounder class

* Fix split-text when working with insert trigger

* Try counteracting the contenteditable's auto surrounding

* Remove matching elements before normalizing

* Rewrite match-type

* Move setting match leaves into build

* Change editing strings

- So that color strings match bold/italic strings better

* Fix border radius of List options menu

* Implement extensions functionality

* Remove some unnecessary code

* Fix split range endOffset

* Type MatchType

* Reformat MatchType + add docs

* Fix domlib/surround/apply

* Satisfy last tests

* Register Surrounder as package

* Clarify some comments

* Correctly implement reformat

* Reformat with inactive eraser formats

* Clear empty spans with RemoveFormatButton

* Fix Super/Subscript button

* Use ftl string for hardcoded tooltip

* Adjust wording
2022-02-22 22:17:22 +10:00
Hikaru Y
eafe426622
Fix new deck not being selected (#1681)
* Improve type annotations in studydeck.py

* Use `super()`

* Explicitly delete widget after closing dialog if parent is None

* Consolidate common cleanup tasks into a function

..., and connect it to `finished` signal

* Fix new deck not being selected

* Remove redundant assignments
2022-02-22 21:51:23 +10:00
RumovZ
131a94dd85
Config for burying interday learning cards (#1680)
* Add config for burying interday learning cards

* Expose bury interday learning config in GUI
2022-02-22 21:37:59 +10:00
RumovZ
337f96fce8
Fix/improve flicker when opening browser (#1679) 2022-02-22 20:33:50 +10:00
RumovZ
ad44dc304d
Fix bury count (#1678) 2022-02-22 20:33:11 +10:00
RumovZ
52865cf284
Cleanup (#1676)
* Pass parents to timer() in mediasync.py

* Fix typo

* Fix deleted widget in `closeTooltip()`

* Pass parent in recursive `progress.timer()`
2022-02-22 20:09:43 +10:00
RumovZ
5e1432ff6b
Mention some PowerShell specific issues (#1675)
* Mention Git for Windows as alternative

* Mention powershell path issue
2022-02-18 19:34:44 +10:00
RumovZ
7741475ae0
Fix various leaks (#1672)
* Fix wrong hook being torn down

* Fix item models not being destroyed

* Add missing gc for FilteredDeckConfigDialog

* Add missing type annotation

* Pass calling widget as parent to QTimer

Implicitly passing `self.mw` as the parent means that the QTimer won't
get destroyed before quitting the app, which also thwarts garbage
collection of any data captured by a passed closure.

* Make `Editor._links` an instance variable

Browser is inserting a closure into this dict capturing itself. As a class
variable, it won't get destroyed, so neither will the browser.

* Make `Editor._links` funcs take instance again

* Deprecate calling progress.timer() without parent

* show caller location when printing deprecation warning (dae)
2022-02-18 19:00:12 +10:00
roxgib
14af96d580
Remove .exec() from QMenus in Deck Browser, Reviewer, and Card Template screens (#1674)
* Call StudyDeck with callback

* StudyDeck w/ callback, remove redundant assignment

* Replace exec() with show() for various dialogs

* Update super init args for Models.__init__

* Make StudyDialog ApplicationModal

* Remove .exec() from various dialogs and menus
2022-02-18 17:18:29 +10:00
Damien Elmes
79df188e2a update bundled Python for Linux builds
removes dependency on libcrypt:
https://forums.ankiweb.net/t/issue-building-2-1-50beta3/17630/8
2022-02-18 15:52:41 +10:00
Damien Elmes
cf247a9053 add some more suggested VS Code extensions 2022-02-18 11:33:54 +10:00
RumovZ
700fc50f7a
View menu (#1668)
* Add main view menu

* Add browser view menu

* Use standard keys for zooming and full screen

* Capitalise menu item names

* Toggle Showing Cards/Notes -> Toggle Cards/Notes

* Explicitly set linux full screen key

on_toggle_fullscreen -> on_toggle_full_screen
2022-02-17 16:31:46 +10:00
Abdo
fd6a78e7cf
Add option to ignore accents in search by default (#1667)
* Add option to ignore accents in unqualified search

* Support ignoring accents in word boundary search

* Update ftl/core/preferences.ftl
2022-02-17 16:30:52 +10:00
Damien Elmes
d1d71ffdbb add back support for custom mount point in congrats screen
This was inadvertently dropped in 478b3a53f1,
but AnkiWeb requires it.

In the future we will need to give these index pages a bit more thought,
as it's not very helpful to be exporting a creation function if we're
automatically mounting as the module is imported. Dropping the automatic
mounting would give us more flexibility, but currently that leads to
a FOUC in night mode, as the webview is revealed prior to a subsequent
web.eval() call being able to fire.
2022-02-17 16:28:48 +10:00
Damien Elmes
9bac5b4cb6 disable automatic mypy invocation in VS Code
The default settings don't understand our folder layout (leading to
errors), and place cache files in the root folder. While there is a
setting to provide extra arguments to mypy which we could use to address
the former, paths like ~/.cache do not appear to be supported. Easier
to just rely on pyright for in-IDE linting, and invoke mypy either
via bazel, or via tools/mypy-watch

+ remove unused dist/ exclude
2022-02-17 13:25:22 +10:00
gnnoh
d29a0beb40
Fix ValueError when exported files have wrong mtime (#1666)
* Fix ValueError when exported files have wrong mtime

Set the `strict_timestamps` argument to `False`, so the media files which have a wrong mtime can be normally added to the zipfile.

* Update CONTRIBUTORS (ankitects#1666)

* Reformat exporting.py
2022-02-16 11:17:20 +10:00
Damien Elmes
94846dc4e3 add label to learning column in deck browser
'Learn' rather than 'Learning' to reduce the width of the column.

Closes #1634
2022-02-16 10:23:57 +10:00