Commit Graph

1752 Commits

Author SHA1 Message Date
RumovZ
ae88f7e593 Add clickable hint to dyndeckconf 2021-02-23 23:14:11 +01:00
RumovZ
5a37b8e2af Add direct col reference to dyndeckconf 2021-02-23 22:31:04 +01:00
Henrik Giesel
8aa8174d4b Fix scrollbar issue in anki-editable component in two ways
- using :host-context(.nightMode) allows for applying the nightmode
  scroll bar inside the component
- apply max-width: 100% to all element within editable, not just images
2021-02-23 15:52:20 +01:00
Damien Elmes
f41ec183c2
Merge pull request #1034 from abdnh/clayout-cloze-shortcuts
Shortcuts to preview clozes in card layout screen
2021-02-22 10:07:16 +10:00
abdo
39f3b6ce93 Shortcuts to preview clozes in card layout screen
Assign Alt+{number} to select cloze cards.
2021-02-21 14:46:53 +03:00
Damien Elmes
13f5ee1ddc tweak update message
- Since we need to show this to new users until AnkiDroid is updated,
use a wording that doesn't seem so out of place to new users.
- Avoid mentioning syncing, since the user may not sync, and the
modSchema() call will allow the user to confirm anyway.
- Let the user know they can change their mind about AnkiDroid by
visiting the preferences.
2021-02-21 19:47:26 +10:00
Damien Elmes
5ae66af5d2 rework v2 scheduler upgrade; drop downgrade
- Rework V2 upgrade so that it no longer resets cards in learning,
or empties filtered decks.
- V1 users will receive a message at the top of the deck list
encouraging them to upgrade, and they can upgrade directly from that
screen.
- The setting in the preferences screen has been removed, so users
will need to use an older Anki version if they wish to switch back to
V1.
- Prevent V2 exports with scheduling from being importable into a V1
collection - the code was previously allowing this when it shouldn't
have been.
- New collections still default to v1 at the moment.

Also add helper to get map of decks and deck configs, as there were
a few places in the codebase where that was required.
2021-02-21 15:50:41 +10:00
bluegreenmagick
d6eac551b1 change _on_click_current to _on_click_index
fix bug where clicking on a blank space below sidebar item
would still trigger currentIndex item's click event
2021-02-20 22:58:02 +09:00
Damien Elmes
2941503bea tweak getFile() arguments in editor to be more readable 2021-02-19 10:18:40 +10:00
Damien Elmes
654f4d65f7 disable card shifting in reposition by default
https://forums.ankiweb.net/t/uncheck-shift-position-of-existing-cards-by-default/7550
2021-02-19 10:09:01 +10:00
Damien Elmes
ab1e59a04d use add-on id if name is blank
https://forums.ankiweb.net/t/support-for-rtl-layout-in-ankiweb-add-on-page/7522
2021-02-16 11:12:05 +10:00
Henrik Giesel
adb002f05f Remove unused imports 2021-02-12 02:16:05 +01:00
Henrik Giesel
87febe489e Allow for passing in custom note type and template 2021-02-12 02:12:03 +01:00
Henrik Giesel
270cef63f4 Allow for passing in custom note types for rendering ephemeral cards 2021-02-12 01:53:03 +01:00
Damien Elmes
6e9dfefb24 Revert "Use new note.ephemeral_card method in clayout"
This partially reverts commit 2483ef4517.
2021-02-12 10:05:46 +10:00
Damien Elmes
35840221bb tweak search wording and tidy up API
- SearchTerm -> SearchNode
- Operator -> Joiner; share between messages
- build_search_string() supports specifying AND/OR as a convenience
- group_searches() makes it easier to negate
2021-02-11 19:57:19 +10:00
Damien Elmes
59ccfe5918 more search bikeshedding
While implementing the overdue search, I realised it would be nice to
be able to construct a search string with OR and NOT searches without
having to construct each part individually with build_search_string().

Changes:

- Extends SearchTerm to support a text search, which will be parsed
by the backend. This allows us to do things like wrap text in a group
or NOT node.
- Because SearchTerm->Node conversion can now fail with a parsing error,
it's switched over to TryFrom
- Switch concatenate_searches and replace_search_term to use SearchTerms,
so that they too don't require separate string building steps.
- Remove the unused normalize_search()
- Remove negate_search, as this is now an operation on a Node, and
users can wrap their search in SearchTerm(negated=...)
- Remove the match_any and negate args from build_search_string

Having done all this work, I've just realised that perhaps the original
JSON idea was more feasible than I first thought - if we wrote it out
to a string and re-parsed it, we would be able to leverage the existing
checks that occur at parsing stage.
2021-02-11 17:11:17 +10:00
Damien Elmes
5c69bccfcf switch some existing code to use SearchTerm(negated=...) 2021-02-11 10:55:02 +10:00
Damien Elmes
397cff9194 split due into 'due today' and 'overdue' 2021-02-11 10:49:36 +10:00
Damien Elmes
67d612926c Revert "experiment with using right click for AND/OR/NOT"
This reverts commit 9048a1ff3c and
manually comments out the setSelectionMode() call.

Switching back to the old behaviour until issues can be worked through.
https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/24
2021-02-11 10:14:26 +10:00
Damien Elmes
2a585c5e5a Revert "add escape hatch for new clicking behaviour, in case it causes problems"
This reverts commit 678756c3e9.
2021-02-11 10:10:45 +10:00
Damien Elmes
88c002f4eb convert qt strings to f-strings with flynt
Also revealed an incorrect type def in editor.py that mypy wasn't
noticing before :-(
2021-02-11 10:09:06 +10:00
Damien Elmes
bb29ce88f3 minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
4d373f4aa3 catch TTS runtime error 2021-02-10 16:30:51 +10:00
Damien Elmes
678756c3e9 add escape hatch for new clicking behaviour, in case it causes problems 2021-02-09 19:29:59 +10:00
Damien Elmes
9ce4b21935 add markdown flag for deck description
Needed so we can display consistently, and gradually transition over
2021-02-09 18:47:19 +10:00
Damien Elmes
cf5e04b011 tweak sidebar appearance
- draw a border between sidebar and main area
- tweak padding

Testing is a pain, because you need to check day mode on the
three platforms, and night mode as well. If you can do it better, PRs
are welcome :-)
2021-02-09 16:23:44 +10:00
Damien Elmes
63b369b8a6 add 'untagged', and make clicking on 'tags' show all tagged cards 2021-02-09 12:50:35 +10:00
Damien Elmes
9048a1ff3c experiment with using right click for AND/OR/NOT
This frees up Ctrl/Shift+left click to behave like in a typical GUI
app. On a Mac users can either two finger click, or Command+click in
conjunction with one of the other modifiers.

https://github.com/ankitects/anki/issues/1011
2021-02-09 11:39:47 +10:00
Damien Elmes
68c4b10dcd move update_search into sidebar.py; fix setFilter()
No idea why neither mypy nor pylint are not noticing
"set_filter_then_search" does not exist. Python tooling. :-(
2021-02-09 10:50:39 +10:00
Damien Elmes
09dfbfe2b9 Partially revert "don't select contiguously with shift+click"
I thought this could work, but users (including myself!) are used to
being able to shift+click to select a region, and this behaviour is
surprising. We're also doing potentially expensive searches for each
extra selected item. I think we may need to switch this behaviour to
the right mouse button instead.

This partially reverts commit c91d21e18e.
2021-02-09 10:37:21 +10:00
Damien Elmes
2a0bc15a0b move flags above card state; change stage label for consistency 2021-02-09 09:54:46 +10:00
Damien Elmes
180efbc578 recent -> today
'Current deck' has moved, and by removing 'due tomorrow', we can drop
the 'today' suffix on the rest of the items.

The keys of the existing translations have not been changed, so
existing translations will not break, but will need to be manually
updated to make them shorter.
2021-02-09 09:50:59 +10:00
Damien Elmes
13aa6f99e4 fix rename/delete on current deck 2021-02-09 09:38:37 +10:00
Damien Elmes
c91d21e18e don't select contiguously with shift+click; enable multiple selection
https://github.com/ankitects/anki/issues/1011
2021-02-09 09:33:32 +10:00
Damien Elmes
7972fa6493 remove 'any flag'; make clicking on flags root do the same thing 2021-02-08 22:52:37 +10:00
Damien Elmes
202cf38446 fix wrong item type being used for recent items 2021-02-08 22:50:48 +10:00
Damien Elmes
05074f2cc1 make decks root search collection; move current deck
Also use explicit 'deck:*' search, to make it more obvious what is
happening
2021-02-08 22:48:45 +10:00
Damien Elmes
a8ddb65e1c add ability to force interval reset
- use trailing ! to force a reset
- use - instead of ..
- tweak i18n messages and error handling
2021-02-08 22:33:27 +10:00
Damien Elmes
b9635ce936 nest NoteWithEmptyCards 2021-02-08 19:11:16 +10:00
Damien Elmes
aa82bb172d add small amount of padding to sidebar
https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/3
2021-02-08 19:01:54 +10:00
Damien Elmes
4ac62f8848 fix media check not updating progress 2021-02-08 16:46:57 +10:00
Damien Elmes
6ac35b30c1 Media check suffered from the same text box slowdown as the importing screen 2021-02-08 16:42:21 +10:00
Damien Elmes
c23b01978d nest progress messages and remove Python wrapper class
The progress messages are only really intended to be consumed by Anki.
If consumption by add-ons was expected, we'd be better off keeping the
wrapper, as the API for oneofs in Python is quite awkward to use.
2021-02-08 16:40:27 +10:00
Damien Elmes
f434cff36f remember last input for 'set due'; add string config; nest config types 2021-02-08 14:10:05 +10:00
Damien Elmes
b56580a8c0 fix rsbackend compat issues 2021-02-08 09:51:51 +10:00
Damien Elmes
6aab9feec1 add (unused) reschedule option back to avoid breaking fastbar 2021-02-08 09:51:40 +10:00
Damien Elmes
704b5e581a Rework reschedule tool
The old rescheduling dialog's two options have been split into two
separate menu items, "Forget", and "Set Due Date"

For cards that are not review cards, "Set Due Date" behaves like the
old reschedule option, changing the cards into a review card, and
and setting both the interval and due date to the provided number of
days.

When "Set Due Date" is applied to a review card, it no longer resets
the card's interval. Instead, it looks at how much the provided number
of days will change the original interval, and adjusts the interval by
that amount, so that cards that are answered earlier receive a smaller
next interval, and cards that are answered after a longer delay receive
a bonus.

For example, imagine a card was answered on day 5, and given an interval
of 10 days, so it has a due date of day 15.

- if on day 10 the due date is changed to day 12 (today+2), the card
is being scheduled 3 days earlier than it was supposed to be, so the
interval will be adjusted to 7 days.
- and if on day 10 the due date is changed to day 20, the interval will
be changed from 10 days to 15 days.

There is no separate option to reset the interval of a review card, but
it can be accomplished by forgetting the card(s), and then setting the
desired due date.

Other notes:

- Added the action to the review screen as well.
- Set the shortcut to Ctrl+Shift+D, and changed the existing Delete
Tags shortcut to Ctrl+Alt+Shift+A.
2021-02-07 21:57:51 +10:00
Damien Elmes
b7c72bca4c fix backup not being taken before full download 2021-02-06 19:01:48 +10:00
Damien Elmes
3cd311191a add opus to supported audio list and sort 2021-02-06 15:11:24 +10:00
Damien Elmes
e30b7fc36a handle remote links in ts pages
Required to avoid loading remote links embedded in deck descriptions
in the webview
2021-02-06 15:03:21 +10:00
Damien Elmes
5662939b70 fix filter saving failing when savedFilters is not set 2021-02-05 22:38:44 +10:00
Damien Elmes
efd8c527a6 use 'contains' instead of 'prefix' search in tag completer 2021-02-05 21:14:35 +10:00
Damien Elmes
dfe3c457e5 use top level defs for protobuf enum cases
While mypy can understand nested references like ConfigBool.Key.COLLAPSE_RECENT,
PyCharm doesn't understand the metaclass syntax, and shows the definitions
as invalid.
2021-02-05 19:26:13 +10:00
Damien Elmes
bb30e8f7bc use constants for other color references
str_color/qcolor() doesn't appear to have been used by any add-ons
except one of mine, so changing the signature should be safe
2021-02-05 18:58:22 +10:00
Damien Elmes
b8d67cdad5 move remaining Filter button items into sidebar
- Closes #976
- Added helper to apply arbitrary colour to an icon.
- Fix #979 - low res icons in night mode.
- The icons and colours are not perfect - please feel free to send
through a PR if you can improve them.
- Convert colors dictionary into module consts, so we can
use code completion.
- Added "Edited Today" and "Due Tomorrow"
- Rename camelCase attribute to snake_case and tweak the wording
of some enum constants. We've already broken compatibility with the
major sidebar add-ons, so we may as well make these changes while we
can.
- Removed Filter button. Currently there is no exposed way to toggle
the Sidebar off - wonder if we still need it?
2021-02-05 18:58:22 +10:00
Damien Elmes
bd730a012e replace sidebar filter shortcut with existing Filter button shortcut 2021-02-05 14:32:56 +10:00
Damien Elmes
a602f0342c fix Qt translations in macOS packaged build 2021-02-04 20:28:25 +10:00
Damien Elmes
3c1fa68460 turn top bar dark when night mode enabled on macOS 2021-02-04 19:19:56 +10:00
Damien Elmes
39c6429fe2 fix broken card styling fix :-) 2021-02-03 22:32:55 +10:00
Damien Elmes
7e8886c352 fix broken card styling 2021-02-03 22:22:12 +10:00
Damien Elmes
168963460f update to latest mypy_protobuf
The handling of enum types has improved - we no longer need to import
separate types at typechecking time.
2021-02-03 13:31:52 +10:00
Damien Elmes
86f8cba22c
Merge pull request #972 from hgiesel/ephemeral
Move ephemeral card functionality from clayout to Note class
2021-02-03 13:10:00 +10:00
Damien Elmes
e683e5c4d7
Merge pull request #973 from hgiesel/mathjaxerror
Render error if MathJax raises error
2021-02-03 13:09:12 +10:00
Henrik Giesel
e5587ffa59 Move copy_page to ts/copy.bzl and rename to copy_files_into_group 2021-02-02 18:20:11 +01:00
Henrik Giesel
803d6fbd3b Render error if MathJax raises error 2021-02-02 18:11:16 +01:00
Henrik Giesel
22a5db8ace Remove unused imports 2021-02-02 17:13:35 +01:00
Henrik Giesel
2483ef4517 Use new note.ephemeral_card method in clayout 2021-02-02 16:47:25 +01:00
Damien Elmes
4a5ef69068 add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
Damien Elmes
6426edb0ac more typing updates 2021-02-02 23:31:55 +10:00
Damien Elmes
4b112950b8
Merge pull request #971 from abdnh/sidebar-checkpoints
Add checkpoints for sidebar drag & drop routines
2021-02-02 22:28:53 +10:00
Damien Elmes
33319e1691
Merge pull request #970 from RumovZ/cleanup-967
Cleanup 967
2021-02-02 22:03:43 +10:00
abdo
2754464147 Add checkpoints for sidebar drag & drop routines
Also save note and reset browser model
2021-02-02 14:58:44 +03:00
Damien Elmes
7e22bc16bc fix: Qt translations not working
Will need to manually confirm this is working in the bundled builds
2021-02-02 21:12:28 +10:00
RumovZ
2499f2ae34 Remove standard button translations 2021-02-02 11:57:35 +01:00
Damien Elmes
4330ab58f5 auto-expand items while dragging 2021-02-02 20:14:14 +10:00
Damien Elmes
a50601ed46 add tag drag & drop support 2021-02-02 20:14:04 +10:00
Damien Elmes
dd54c10e71
Merge pull request #968 from abdnh/sidebar-expand-matches
Expand sidebar match trees one level
2021-02-02 19:03:04 +10:00
Damien Elmes
467064f873 collapsed->expanded in other tag uses for consistency 2021-02-02 18:52:57 +10:00
Damien Elmes
52b256663f collapsed->expanded in TagTreeNode 2021-02-02 18:52:57 +10:00
RumovZ
14775445df Add docstring to browser.__ini__ 2021-02-02 09:48:55 +01:00
RumovZ
16462941ab Remove actionCreateFilteredDeck2 and use modifier 2021-02-02 09:29:09 +01:00
Damien Elmes
0bf2538989 remove sidebar margins 2021-02-02 16:35:42 +10:00
Damien Elmes
7fc32db0c9 fix: slowdowns after import; hard to read popup
QTextEdit() will pin the CPU at 100% for seconds to minutes when
fed a large string to display - work around it by switching to
QPlainTextEdit().

Also strip HTML before showing the user - easier to read, and less
text to display. And turn off word wrap, as it makes it easier to skim,
and further reduces the work the widget needs to do.

https://forums.ankiweb.net/t/big-issue-where-anki-gets-slow-when-you-import-this-deck/7050
2021-02-02 15:49:47 +10:00
abdo
ee1ed033a2 Hide sidebar items when there is no match 2021-02-02 05:41:45 +03:00
abdo
6f5d1bca3f Add more sidebar section roots 2021-02-02 04:51:45 +03:00
Damien Elmes
b7bfe58afe fix sync warning caused by mistake in typing work 2021-02-02 10:43:49 +10:00
Damien Elmes
3a8fce69dd ditch QSortFilterProxyModel in favour of our own code
Simpler and approximately twice as fast in a large collection:

old approach
search for a: 371ms
search for an: 260ms

new approach:
search for a: 171ms
search for an: 149ms

Still todo: add enum defs for the other root categories, update
the _section_root() calls, and update is_expanded() to use the new
extra types
2021-02-02 10:40:50 +10:00
RumovZ
b450c8d45c Add remaining type hints to dyndeckconf etc. 2021-02-01 23:46:56 +01:00
RumovZ
c18af2a0a9 Merge branch 'master' into dyn-deckconf 2021-02-01 23:33:41 +01:00
RumovZ
2ddb4edbb0 Rename standard buttons to have transaltions 2021-02-01 23:20:57 +01:00
RumovZ
6c7b195da8 Make browser links unfocusable
Since Enter would trigger Accept anyway, there is no point in them
having focus.
2021-02-01 21:17:15 +01:00
RumovZ
4666ba8b70 Enable renaming from dyndeck dialogue 2021-02-01 21:02:22 +01:00
RumovZ
8065e73ef8 Add cross links for second dyndeck filter 2021-02-01 19:10:05 +01:00
RumovZ
0d37254238 Style browser-from-filtered-deck button
Use theme color and add hover effect.
2021-02-01 18:01:57 +01:00
abdo
c96248d67f Expand sidebar match trees one level
See 132bb5ff36
2021-02-01 19:12:43 +03:00
Damien Elmes
a56b09b987 add a bunch of return types 2021-02-01 23:53:23 +10:00
RumovZ
4d097b995d Add button in dynDeckConf to search in browser 2021-02-01 13:55:03 +01:00
Damien Elmes
f15715fb07 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
RumovZ
0949cdc73e Rename "Filtered Deck from Current Filter" 2021-02-01 12:09:37 +01:00
Damien Elmes
84f8d7f604 add some types to main.py 2021-02-01 20:59:18 +10:00
RumovZ
6b1d5f14e8 Change filtered-deck shortcut in browser to Ctrl+G 2021-02-01 11:59:16 +01:00
RumovZ
6de6e5f339 Make browser accept optional args and add reopen
That way, the caller doesn't have to hold a reference to the browser and
explicitly call it again, if it wants to search for something specific.
Also, if the browser was closed and opened for a single-card-search, it
now won't perform a redundant current-deck-search first.
2021-02-01 11:54:28 +01:00
Damien Elmes
98f4b3db81 add types to utils.py
The function signatures for things like getFile() are awful, but
sadly are used by a bunch of add-ons.
2021-02-01 20:23:48 +10:00
RumovZ
d2024d1d1e Fix pylints and type annotations in dyndeckconf
Also fix int representation of learning steps.
2021-02-01 09:56:10 +01:00
RumovZ
5aac81d15f Make DialogManager accept kwargs
When opening a dialogue accepting multiple optional arguments, relying
on position is error-prone and requires passing Nones to fill unused
parameter slots.
2021-02-01 08:50:19 +01:00
Damien Elmes
d13762bd32 add types to editor.py 2021-02-01 17:28:35 +10:00
Damien Elmes
1f6ed0739f
Merge pull request #962 from hgiesel/editordirs
Make editor a rollup package within data/web/js
2021-02-01 13:40:54 +10:00
Damien Elmes
328c86d3a5 add missing types to sidebar.py 2021-02-01 09:51:46 +10:00
Damien Elmes
66c8ee3e0a add missing types to browser.py 2021-02-01 09:39:55 +10:00
RumovZ
011b562038 Add current-filter-to-filtered-deck action 2021-01-31 23:16:49 +01:00
RumovZ
52867dfa6c Make dyndeckconf a registered dialogue 2021-01-31 22:37:08 +01:00
Henrik Giesel
70b7cbcd4a Move editor css to editor directory 2021-01-31 19:03:40 +01:00
RumovZ
0960ea6ece Rework dynndeckconf
- Handle deck building inside class. New deck is built unless caller
  passes filtered deck.
- If no deck is passed and current deck is filtered, copy settings.
- Remove exec_().
2021-01-31 18:20:47 +01:00
Henrik Giesel
2ab06a6540 Move editor to /ts/editor 2021-01-31 14:15:03 +01:00
Henrik Giesel
859a52ab15 Fix type issues 2021-01-31 13:34:39 +01:00
Henrik Giesel
33160dcb00 Make editor a rollup package 2021-01-31 13:34:37 +01:00
RumovZ
13c6921da1 Remove protobuf filters whole_col and current_deck 2021-01-31 11:12:49 +01:00
Damien Elmes
6c483bb577 add public wrappers for remaining backend functions 2021-01-31 18:56:16 +10:00
Damien Elmes
67cb147493 move rsbridge into _backend 2021-01-31 18:55:45 +10:00
Damien Elmes
9d853bbb03 start work on more clearly defining backend/protobuf boundaries
- anki._backend stores the protobuf files and rsbackend.py code
- pylib modules import protobuf messages directly from the
_pb2 files, and explicitly export any will be returned or consumed
by public pylib functions, so that calling code can import from pylib
- the "rsbackend" no longer imports and re-exports protobuf messages
- pylib can just consume them directly.
- move errors to errors.py

Still todo:

- rsbridge
- finishing the work on rsbackend, and check what we need to add
back to the original file location to avoid breaking add-ons
2021-01-31 18:55:45 +10:00
RumovZ
3e69d39a25 Add missing sidebar onClicks 2021-01-31 08:56:34 +01:00
Damien Elmes
cb805cf355 Merge branch 'more-backend-search' into main 2021-01-31 14:21:51 +10:00
Damien Elmes
126b642115 disable multiple selection for now 2021-01-31 14:02:38 +10:00
Damien Elmes
18f0b78716 disable dragging of unsupported items 2021-01-31 13:46:31 +10:00
Damien Elmes
4579740df6 support dragging multiple decks at once 2021-01-31 13:46:31 +10:00
Damien Elmes
49a40e7178 add missing check for on_done==None in with_progress() 2021-01-31 13:46:31 +10:00
Damien Elmes
28ff061c19 support drag&drop of decks in sidebar 2021-01-31 13:46:31 +10:00
Damien Elmes
8410330f94 move drag/drop deck logic to backend 2021-01-31 13:46:31 +10:00
RumovZ
9bfe8e3840 Remove search button and reword search bar hint 2021-01-30 19:23:40 +01:00
RumovZ
b0890b0e47 Manually namespace enum variants in SearchTerm
In protobuf "...enum values use C++ scoping rules, meaning that
enum values are siblings of their type, not children of it.
Therefore, [an enum variant] must be unique within [a message],
not just within [the enum.]"
So we must prefix enum variants with their enum's name, but can
also call them directly from the message namespace.
The protobuf crate is smart, though, and strips the prefixes.

(Simultaneously change some SearchTerm variant names.)
2021-01-30 17:56:29 +01:00
RumovZ
375794893f Replace leftover _named_filter with _filter_func 2021-01-30 17:39:21 +01:00
Henrik Giesel
126af1fef3 Fix focus on first field upon opening editor 2021-01-30 14:20:14 +01:00
RumovZ
9e9d8b9c7a Build list in focusCid and specify exception
model.cards may be a protobuf sequence but focusCid needs list's index
method, so convert to list, but only if needed.
2021-01-30 13:15:46 +01:00
RumovZ
5425b00d2b Import SearchTerm from collection in aqt 2021-01-30 12:51:24 +01:00
RumovZ
26e5235846 Fix type annotations in browser search 2021-01-30 11:24:33 +01:00
RumovZ
63e8b44629 Update docstrings for browser search 2021-01-30 11:05:48 +01:00
RumovZ
9c4cc88b47 Auto search and check input before model search
- Search for current deck automatically on browser setup.
- Hide current deck and current card searches.
- Check user search input before passing it on to the model, so invalid
  searches don't change TableView.
2021-01-30 10:53:42 +01:00
Damien Elmes
b66bedbc9f
Merge pull request #957 from hgiesel/fieldsshadow
Implement editor as Web Component
2021-01-30 15:13:58 +10:00
Damien Elmes
705012164b move Rating up a level
More ergonomic, and will allow reuse if we expose prop:rated in
the future.
2021-01-30 11:54:39 +10:00
Damien Elmes
cb6b88da0f simplify nid/nids searches, and ditch helper function
- IdList could be re-used for a cids: search in the future if required.
- Embedding the message means it's easy to access from Python as
an attribute of SearchTerm.
2021-01-30 11:37:00 +10:00
Damien Elmes
1adc9952f4 simplify Dupe message and ditch helper function
Calling code doesn't need to know about the existence of such helpers;
it can just rely on code completion to discover the required arguments.
2021-01-30 11:10:26 +10:00
Damien Elmes
5e6dd54c8e export SearchTerm from collection.py, and avoid exporting embedded items 2021-01-30 11:01:11 +10:00
Damien Elmes
52bac7a7a1 use a separate enum for the is:* searches 2021-01-30 10:49:00 +10:00
Damien Elmes
22b80c2dd5 combine forgot_in_days and studied_today into a more general 'rated' 2021-01-30 10:26:23 +10:00
Damien Elmes
177036d0c1
Merge pull request #958 from hgiesel/zindexedtopbar
Make sticky topbar have a positive z-index
2021-01-30 09:14:50 +10:00
RumovZ
2ca4f31fc8 Update search history only after successful search
Ergo, don't save invalid searches, but also save searches normalised so
equivalent searches get saved only once.
2021-01-29 23:05:51 +01:00
RumovZ
671c6a7b3e Rework search initialisation
- Remove _searchPrompt.
- Add placeholder prompt.
- Move search for current card from browser to caller. (Thus, support
  current card search even with opened browser.)
2021-01-29 21:07:42 +01:00
Henrik Giesel
61346cf1f7 Rename editingContainer -> editingArea; editingArea -> editable
* Custom elements are now namespaces with `anki-`
* The element names are inspired by summernote, which have the same
  naming scheme of "editingArea > editable"
2021-01-29 20:32:21 +01:00
Henrik Giesel
2e72de4af0 Reorder methods / properties 2021-01-29 20:13:02 +01:00
Henrik Giesel
e37fd2e091 Remove unnecessarily observed attribute 2021-01-29 20:11:00 +01:00
Henrik Giesel
aa924ac821 Add semicolon in js message 2021-01-29 19:48:17 +01:00
Henrik Giesel
3559834bc9 Make forEditorField more cheaper to execute by avoiding casting to Array 2021-01-29 19:38:55 +01:00
RumovZ
c299e271e8 Refactor search_string() and FilterToSearchIn
See #955.
2021-01-29 18:27:33 +01:00
Henrik Giesel
79dc0ecf86 Remove explicit ids, as they are not necessary anymore 2021-01-29 18:07:31 +01:00
Henrik Giesel
5e67e706fb No need to set initial values for editing area base CSS 2021-01-29 17:51:26 +01:00
Henrik Giesel
32ee863577 Remove checking for class names for instance checks 2021-01-29 17:41:27 +01:00
Henrik Giesel
982372beae Put HTML initialization into web component constructor
* disconnectedCallback should remove event listeners and free other resources
* attributes belong to connectedCallback
2021-01-29 15:50:34 +01:00
Henrik Giesel
0beefc0699 Move setting of index to connectedCallback 2021-01-29 14:54:59 +01:00
Henrik Giesel
fe87f986d3 Remove user styling in editor again for now 2021-01-29 14:54:59 +01:00
Henrik Giesel
594fc9bebd Fix focus change on tab 2021-01-29 14:54:59 +01:00
Henrik Giesel
6e907fd8b6 Move styling attributes from editor to editing-area that are for editing area 2021-01-29 14:54:58 +01:00
Henrik Giesel
a620bf91a8 Make button highlight white in nightMode 2021-01-29 14:54:58 +01:00
Henrik Giesel
3eade1c64d Make the text color part of the base style in editor 2021-01-29 14:54:58 +01:00
Henrik Giesel
af3753948a Allow stylesheet of note type take effect on editor fields 2021-01-29 14:54:58 +01:00
Henrik Giesel
8a525d3643 Use currentField.getSelection instead of window.getSelection 2021-01-29 14:54:58 +01:00
Henrik Giesel
08a6f8f02f Use new focusEditingArea and blurEditingArea to delegate to editing area 2021-01-29 14:54:58 +01:00
Henrik Giesel
aed38de228 Fix dupes, but also make sticky, and centered to draw more attention 2021-01-29 14:54:58 +01:00
Henrik Giesel
bec709c7a9 Update setFonts and setBackgrounds 2021-01-29 14:54:58 +01:00
Henrik Giesel
db0c776210 Fix inListItem for shadow roots 2021-01-29 14:54:58 +01:00
Henrik Giesel
e0d1450ce0 Rename fieldContainsInlineContent to containsInlineContent to reflect new usage 2021-01-29 14:54:58 +01:00
Henrik Giesel
7dc4b8818c Isolate styling of editing-area into new scss file 2021-01-29 14:54:58 +01:00
Henrik Giesel
1db71805d3 Create a rough draft of the editor web component 2021-01-29 14:54:58 +01:00
Damien Elmes
d558f08a74 remove debug statement 2021-01-29 23:21:57 +10:00
Henrik Giesel
4b7d406559 Make sticky topbar have a positive z-index 2021-01-29 14:21:32 +01:00
Damien Elmes
79239c89b7 move saved search code into sidebar.py, and remove from Filter button 2021-01-29 23:05:30 +10:00
Damien Elmes
132bb5ff36 add expand/collapse children options 2021-01-29 22:54:00 +10:00
Damien Elmes
6ba5ff5a01 place each sidebar section under its own collapsible parent node
- Allows for group operations like "clear unused tags"
- Allows users to hide groups they're not interested in
2021-01-29 22:11:05 +10:00
Damien Elmes
5ff7944a26 add getter/setter for boolean config values 2021-01-29 21:03:19 +10:00
RumovZ
349bd9d681 Use proper docstrings 2021-01-29 09:40:21 +01:00
RumovZ
1fb6024454 Rename filters added_in etc. to added_in_days 2021-01-29 09:38:13 +01:00
Damien Elmes
4ac9ad1407 show actual error when graphData fails
The original reason for the catch-all message was users with bad
data such as decimal intervals, but those get automatically coerced
these days. The common case should now be invalid search strings, which
we can show verbatim.
2021-01-29 14:39:05 +10:00
Damien Elmes
57c53632a6 Revert "Make sidebar search matching work with full_name instead of name"
This reverts commit 6850e0f78e.

Using the full name caused issues with highlighting:
https://github.com/ankitects/anki/pull/951#issuecomment-769516003

Let's revert this for now and see if demand presents itself.
2021-01-29 13:18:28 +10:00
Damien Elmes
151cf52718 vary sidebar highlight with theme 2021-01-29 13:15:38 +10:00
Damien Elmes
9584efc066
Merge pull request #951 from abdnh/sidebar-search
Add search bar to the sidebar
2021-01-29 11:32:26 +10:00
abdo
903008f2bd Handle sidebar refreshing while searching 2021-01-29 04:20:15 +03:00
Damien Elmes
64af4dfe7e drop potentially slow regex usage in cloze check
Closes #956, thanks to Henrik.
2021-01-29 11:15:33 +10:00
abdo
9492c8305e Wait for some time before performing sidebar search 2021-01-29 03:45:16 +03:00
abdo
6850e0f78e Make sidebar search matching work with full_name instead of name 2021-01-29 02:36:13 +03:00
RumovZ
f04228990d Add browser_search helper in mw 2021-01-28 20:51:32 +01:00
RumovZ
251fe50660 Fix search calls in addcards 2021-01-28 20:01:20 +01:00
RumovZ
423d7e5098 Use backend filter for findDupes and handle excep. 2021-01-28 19:49:16 +01:00
RumovZ
a930aa41f0 Use backend nid filter in addcards and mediacheck 2021-01-28 18:59:20 +01:00
RumovZ
407358ab68 Use backend nid filter in browser 2021-01-28 16:21:56 +01:00
RumovZ
1635f20af3 Prevent search prompt from being saved as a filter
Normalisation would render it useless.
2021-01-28 13:31:08 +01:00
RumovZ
99cb68513c Use backend filter for search prompt 2021-01-28 13:26:52 +01:00
RumovZ
77765d4896 Replace remaining literal searches in aqt 2021-01-28 11:19:07 +01:00
RumovZ
ea46e24662 Use col instead of backend in aqt for search strs 2021-01-28 11:17:24 +01:00
Damien Elmes
2224fce936 fix crashes when activating context menu/items while searching 2021-01-28 19:12:07 +10:00
Damien Elmes
b148095243 basic match highlighting 2021-01-28 18:58:51 +10:00
Damien Elmes
8b08687b0c basic tree-based filtering with a sort proxy
Some things left to do:

- instead of searching on each keystroke, have the keystroke start
a timer and wait 600-1000ms before performing the search
- handle the case .refresh() is called while searching

It would also be nice to have some visual distinction between matching
rows and their non-matching parents.
2021-01-28 18:51:18 +10:00
Damien Elmes
fbf2f673f4 fix sidebar model.parent() returning invalid values
Triggered a crash when using a model proxy.
2021-01-28 17:48:33 +10:00
Damien Elmes
f45d51c92d
Merge pull request #952 from hgiesel/fieldsflex
Deal with inline content vs block content and <br> in editor.ts
2021-01-28 15:49:31 +10:00
Damien Elmes
a03da5ce89 add type check to textFormat arg 2021-01-27 14:22:17 +10:00
Henrik Giesel
bf7ff65af6 Rename fieldIsInInlineMode to fieldContainsInlineContent 2021-01-27 02:35:14 +01:00
Henrik Giesel
d9f00c4839 Remove unused helper functions 2021-01-27 00:55:00 +01:00
Henrik Giesel
b2b17f4c3d Recreate border-spacing with margins for #fields 2021-01-27 00:50:26 +01:00
Henrik Giesel
9b5d915983 Change nodeIsInline logic to be more typesafe 2021-01-26 23:49:48 +01:00
Henrik Giesel
feddf96f2a Change logic to detect inline elements, as the display style property may not be set after setting innerHTML 2021-01-26 23:42:04 +01:00
abdo
208c713e39 Add search bar to the sidebar
https://github.com/ankitects/help-wanted/issues/6
2021-01-27 01:41:57 +03:00
Henrik Giesel
520c4a3b4d Make #fields display correctly 2021-01-26 23:17:50 +01:00
Henrik Giesel
e481452114 Make fields div instead of table + implement fieldIsInInlineMode logic 2021-01-26 23:00:55 +01:00
Henrik Giesel
335267d42e Strip trailing newline if inline elements logic 2021-01-26 21:26:04 +01:00
Damien Elmes
322788133b tooltip() instead of print() when no tts tag matches
Can help with debugging user error like an incorrectly-typed language
code. Don't ask me how I know. :-)
2021-01-26 20:37:24 +10:00
Damien Elmes
e324f06348
Merge pull request #944 from Arthur-Milchior/help
NF: HelpPage in an enum
2021-01-26 11:33:39 +10:00
Damien Elmes
644cc46dea
Merge pull request #897 from hgiesel/statssearch
Triggering searches from the stats screen.
2021-01-26 11:31:36 +10:00
Arthur Milchior
e0a2d90a68 NF: HelpPage in an enum
Hopefully, this can help with updating on next manual update and maybe even linking to manual translation
2021-01-26 02:16:37 +01:00
Damien Elmes
0a0de2ce7b
Merge pull request #945 from RumovZ/dyndeck-search
Normalize dyndeck search and handle exception
2021-01-26 09:24:56 +10:00
Damien Elmes
a82744a3e5 load sidebar in background
Allows the UI to repaint during processing, but will still block
DB operations until the call completes.
2021-01-26 09:02:08 +10:00
RumovZ
52c27e7b99 Normalize dyndeck search and handle exception 2021-01-25 23:21:32 +01:00
RumovZ
060fdc824b Move show_invalid_search_error to utils 2021-01-25 23:19:19 +01:00
Henrik Giesel
759ed17963 Move dispatch logic from Histogram to individual graphs 2021-01-25 16:34:44 +01:00
Henrik Giesel
a7c8b021dd Satisfy formatter 2021-01-25 13:46:44 +01:00
Henrik Giesel
fdf4c6628f Add browserSearch bridge command 2021-01-25 13:44:19 +01:00
Damien Elmes
31a3add848 fix finished screen not showing when learning cards due later 2021-01-25 21:12:57 +10:00
Arthur Milchior
5c69f2c324 Correct browse help link 2021-01-23 14:48:29 +01:00
Damien Elmes
2a875ffc55
Merge pull request #934 from hgiesel/graphprefs
Add GraphsPreferences API to graphs for setting persistent preferences
2021-01-23 21:24:41 +10:00
Damien Elmes
37ca8afaf6 minor wording tweak: GraphsPreferences -> GraphPreferences 2021-01-23 20:47:45 +10:00
Damien Elmes
b16f6cbcce
Merge pull request #938 from hgiesel/editorflex
Small refactor of topbar buttons
2021-01-23 20:09:42 +10:00
Damien Elmes
8d5dca4bda move sidebar code from browser.py to sidebar.py and tidy up
https://github.com/ankitects/help-wanted/issues/6

Some notes:
- use our own routine to toggle the sidebar, which avoids a useless
refresh on browser close, and allows us to limit the delayed loading
to initial browser load.
- add-ons that limited themselves to the browser_will_build_tree hook
should theoretically continue working; ones that were monkey patching
will likely break. A few appear to be broken at the moment anyway,
so it's probably a good time to be making this change.
2021-01-23 19:59:12 +10:00
Damien Elmes
9db3f0dd19 drop tags/decks/etc from Filter button
https://github.com/ankitects/help-wanted/issues/6

These are a relic from when the sidebar defaulted to off, and I don't
think enough people are using them to bother keeping them around.
Once the the card state and saved filter functionality moves into the
sidebar and top menus, we may be able to remove the Filter button
completely.
2021-01-23 18:21:44 +10:00
Henrik Giesel
bf130d1da0 Change the function name in genbackend.py 2021-01-22 20:05:28 +01:00
Henrik Giesel
de71123ab4 Rename GraphsPreferencesOut to simply GraphsPreferences 2021-01-22 19:39:03 +01:00
abdo
0110102ea2 Render card templates as trees in the sidebar
Reusing the note type icon and not caring about saving collapse state
for now.
2021-01-22 17:49:20 +03:00
Henrik Giesel
d1ada88657 Successfully send post request to rust 2021-01-22 14:37:24 +01:00
Henrik Giesel
054c30a695 Add non-functioning logic for settings graphs preferences 2021-01-22 13:14:35 +01:00
Henrik Giesel
665a13e378 Add GraphsPreferences endpoint to backend 2021-01-22 13:13:48 +01:00
Henrik Giesel
1df6c5f596 Avoid highlighting of toprightbuttons to shift the topbar 2021-01-22 12:53:45 +01:00
Henrik Giesel
9226d50185 Space items by using margins instead of spaces
* also changed name of topbutton container back to topbutsOuter as it is clearer
* starting with Chromium 83, `row-gap` would be better suited for this
2021-01-22 12:17:10 +01:00
Henrik Giesel
97f8f1b89e Switch from floating windows and clearfix to flex and justify-content: space-between 2021-01-22 11:37:11 +01:00
Damien Elmes
0c35d30979
Merge pull request #935 from abdnh/sidebar-nt
Add manage note types menu item to the sidebar
2021-01-22 14:21:28 +10:00
abdo
426ea1aba9 Move the logic for selecting a note type to models.py 2021-01-22 05:56:39 +03:00
Henrik Giesel
1f4de7fe4b Adjust the positioning of the editor toolarea via CSS 2021-01-21 21:36:33 +01:00
Henrik Giesel
2946843b81 Remove image click event handler, as it never takes place
* className of fields will be "field clearfix", never just "field"
2021-01-21 20:50:17 +01:00
Henrik Giesel
e91a4b4362 Remove javascript resizing code from editor.ts 2021-01-21 19:59:16 +01:00
abdo
918bba6365 Add manage note types menu item to the sidebar 2021-01-21 20:27:20 +03:00
Damien Elmes
6d8a9a7ef5
Merge pull request #930 from hgiesel/editorts
Refactor editor.ts
2021-01-21 10:44:11 +10:00
Henrik Giesel
6262997599 Explicitly execute code deactivating button focus from editor.py 2021-01-20 17:06:08 +01:00
abdo
0fc4c21dcc Add filter remove/rename actions to the sidebar 2021-01-20 03:26:53 +03:00
Henrik Giesel
cfc8e34cf0 Remove jQuery from most top functions, and avoid waiting for jquery load 2021-01-19 03:52:46 +01:00