Commit Graph

9464 Commits

Author SHA1 Message Date
Damien Elmes
e50d40cedf Make editor.cleanup() idempotent
Hammering the esc key as a dialog loads can cause it to be run more
than once, leading to an error message.
2022-05-25 22:04:50 +10:00
Damien Elmes
496e074f29 Possible fix for Qt 6.3 crashes
As mentioned on #1879, the dialog.deleteLater() call appears to be
causing crashes on some systems on Qt 6.3. Explicitly destroying the page
prior to the containing webview appears to work around the issue.
2022-05-25 21:46:47 +10:00
Damien Elmes
9b0729970e Fix deck options sticky bar at top disappearing on scroll
Issue was introduced in 7922f18296
when the styling was moved into base.scss. From what I can tell, there
are two locations where the current styling is required:

- the editor, to ensure the tags are shown at the bottom
- the change notetype screen, which requires this styling for a sticky
bar at top

I'm no CSS guru, so if someone thinks this could be solved in a better
way, please submit a follow-up PR.

Closes #1782
2022-05-23 16:10:45 +10:00
Henrik Giesel
7a77a8f2f9
Add getNoteId to exports (#1884) 2022-05-23 09:14:36 +10:00
Damien Elmes
ae18ba2a05 Switch editor to full MathJax package to fix broken autoloads
Re: https://forums.ankiweb.net/t/anki-2-1-53-release-candidate/20122/2

Autoloads in MathJax are asynchronous, and the caller is expected to
use asynchronous APIs when they are in use [1]. The editor uses the synchronous
tex2svg(), which throws a "MathJax retry" error when an autoload package
has not yet loaded. Attempting to use the package before it has loaded
appears to break future invocations as well, so the package fails to work
at all until a new webview is created.

The following HTML will reproduce the issue when added to a single card
in a new profile:

```
<strong>6&nbsp; &nbsp;&nbsp;</strong>Every combination of <anki-mathjax>\boldsymbol{v}=(1,-2,1)</anki-mathjax> and <anki-mathjax>\boldsymbol{w}=(0,1,-1)</anki-mathjax> has components that add to&nbsp; _____.<br>
```

Ideally we'd switch the MathJax rendering to be asynchronous, but that
didn't work well when I tried it in #1862. For now I've just switched
to the full package, which adds about 130KB to the final minified JS
(2.76MB), and likely slows down editor loading somewhat.

[1] https://github.com/mathjax/MathJax/issues/2557#issuecomment-727655089
2022-05-21 14:01:38 +10:00
Damien Elmes
450f00b843 Update setting for latest Rust Analyzer 2022-05-21 13:34:19 +10:00
Damien Elmes
f6ecddef5f Bump version 2022-05-20 18:01:41 +10:00
Damien Elmes
0d8657b30e Update translations 2022-05-20 17:58:16 +10:00
Damien Elmes
82196753ec Rework display of available cards in custom study
In v3, it's more informative to show the count of child decks separately,
since increasing the limit of the current deck does not increase the limits
of child decks. When we rework the decks list in the future, a tooltip
will hopefully provide an easier way for users to see where cards are
available, and where limits are being applied.

Closes #1868
2022-05-20 17:52:02 +10:00
Damien Elmes
aed3988d48 Update translations 2022-05-19 12:49:38 +10:00
Damien Elmes
8b1afc7e3a Reveal cloze answers in MathJax preview
Closes #1862
2022-05-19 12:48:12 +10:00
Abdo
515e77b0f4
Add the previewer_did_init hook (#1882) 2022-05-19 11:10:12 +10:00
BlueGreenMagick
6ddbf7bc10
Fix graphs tooltip incorrect position (#1872) 2022-05-19 11:08:57 +10:00
Abdo
638286a3fc
Add the reviewer_will_replay_recording hook (#1877) 2022-05-18 13:44:56 +10:00
RumovZ
a5ad95ca41
Fix Rust Analyzer recommendation (#1878) 2022-05-18 13:40:10 +10:00
RumovZ
58370d6757
Fix #1874 (#1875)
Probably a race condition. `.get_row()` is not a reliable check for card
or note existence, because it returns from an outdated cache,
if the backend is currently blocked.
2022-05-18 13:34:51 +10:00
Henrik Giesel
dba12e8cb3
Allow style tags in HTML editor (#1870) 2022-05-17 16:37:20 +10:00
Damien Elmes
a451fec5a1 Fix new card positions being included in future due graph
Introduced in f60de39015

https://forums.ankiweb.net/t/anki-2-1-52-qt6-stats-bug-future-due-backlog/20016
2022-05-16 15:14:15 +10:00
Henrik Giesel
826e135510
Update Svelte to 3.48.0 (#1867) 2022-05-16 14:47:38 +10:00
Henrik Giesel
1b18005d6e
Transform <br> in Mathjax to newlines (#1866)
* Transform <br> in Mathjax to newlines

* Add missing quantifier
2022-05-16 14:42:10 +10:00
Damien Elmes
a070bec03c Allow alt tags when pasting images
https://forums.ankiweb.net/t/do-not-strip-alt-attribute-when-pasting-images-from-the-web/20007
2022-05-16 14:32:24 +10:00
Damien Elmes
e025f2f879 Only organize Python imports automatically
It's causing changes that aren't reproduced/picked up by prettier:

https://github.com/ankitects/anki/pull/1862#discussion_r870395750
2022-05-13 13:44:48 +10:00
Henrik Giesel
3b8aa97396
Use same config for editor and reviewer Mathjax (#1865)
* Remove custom config and use tex-chtml-full for editor Mathjax

* Add mathjax package in /ts

* Share mathjax config between tex-svg and tex-chtml

* Use "[+]" in Mathjax config again

* Remove mention of MathJaxReady

* Satisfy eslint
2022-05-13 13:23:35 +10:00
Abdo
f22d8015a6
Add some helper functions to AVPlayer (#1864) 2022-05-13 13:08:05 +10:00
Henrik Giesel
b6fb64fde1
Implement cloze buttons in Mathjax editor (#1860)
* Introduce RichTextClozeButtons

* Implement cloze buttons in Mathjax editor
2022-05-13 13:04:20 +10:00
Henrik Giesel
52438fe4c9
Move focus into HTML editor when shown (#1861)
* Move focus into input field, when input is shown

* Change trapFocusOut to move focus into available inputs

- This means that e.g. closing the HTML editor with focus in it will
  focus the visual editor in turn

* Prevent Control+A unselecting tag editor when no tags exist
2022-05-13 13:02:03 +10:00
Henrik Giesel
de2cc20c59
Change how resizable images work (#1859)
* Add ResizableImage.svelte in ts/editable

* Set image constrained via attributes instead of managed style sheet

* Implement new constrained size method

* Turn WithImageConstrained.svelte into normal ts file

* Introduce removeStyleProperties

Removes "style" attribute if all style properties were cleared

* Avoid --editor-width and use one variable set on container

* Disable shrinking if already smaller than shrunken size

* Add button to restore image to original size

* Don't allow restoring original size if no custom width set

* Bottom-center HandleLabel

* Satisfy svelte-check
2022-05-13 12:57:07 +10:00
BlueGreenMagick
fb5521eeed
remove image.style.height on resize (#1856) 2022-05-11 10:06:34 +10:00
Damien Elmes
ab1c23953e Update translations 2022-05-10 13:18:07 +10:00
RumovZ
6c807c1b2e
Fix review queue if limit is reached (#1855) 2022-05-10 12:11:35 +10:00
Henrik Giesel
89530c5f24
Change sequence of Mathjax escaping (#1854) 2022-05-10 11:54:06 +10:00
Henrik Giesel
6043d2f5a2
Set editor size to 1.6 on Windows as well (#1853) 2022-05-10 11:48:11 +10:00
Henrik Giesel
96d9539b9d
Fix activeName updating wrongly when selecting previous tag from invalid tag (#1851) 2022-05-10 11:45:41 +10:00
Abdo
45b12ca104
Store rendered side in TemplateRenderContext (#1852)
* Store rendered side in TemplateRenderContext

* Move _question_side up with the other simple properties (dae)
2022-05-10 11:44:44 +10:00
BlueGreenMagick
68482d37a1
select all tags with Ctrl+A (#1847) 2022-05-10 11:39:54 +10:00
Damien Elmes
1b48d3e3d1 Mention eslint --fix in docs
https://github.com/ankitects/anki/pull/1847#issuecomment-1120954217
2022-05-10 11:39:15 +10:00
BlueGreenMagick
9d98c62d50
Fix when tooltip changes before tooltipObject is created (#1845)
It can happen in TagWithTooltip.svelte
when a tag is normalized beause of leading/trailing delimiter
2022-05-10 11:36:54 +10:00
RumovZ
890b28c1e8
Fix undisruptive formatting issues (#1848)
* Skip unparsable pylib files with black

This was causing black to return a non-zero code, preventing the
subsequent isort from running.

* Organise imports on save
2022-05-09 20:00:20 +10:00
BlueGreenMagick
fc8b976ca8
fix typo. Shortcut uses on:action not on:click (#1846) 2022-05-09 19:55:35 +10:00
BlueGreenMagick
faa21266db
Fix caret jumping to start when unselecting autocomplete suggestion (#1844) 2022-05-09 11:15:56 +10:00
BlueGreenMagick
cc374996cc
align tag icon and text (#1843) 2022-05-09 11:15:44 +10:00
Abdo
7c543eeb2f
Add the av_player_will_play_tags hook (#1842)
A general version of the reviewer_will_play_question_sounds and reviewer_will_play_answer_sounds hooks
2022-05-09 11:08:34 +10:00
Damien Elmes
d946e5ddd5
Fix for crash with invalid dates on Windows (#1837)
https://forums.ankiweb.net/t/bug-report-crashing-when-opening-deck-browser/19768

Caused by a note mtime that was 1000x larger than it should have been.
Check DB will now fix this case (but there are others it still does not
cover, such as invalid card/note IDs).

https://docs.rs/chrono/0.4.19/x86_64-pc-windows-msvc/src/chrono/sys/windows.rs.html#128
2022-05-07 10:30:23 +10:00
Henrik Giesel
df1f7ff96c
Replace sequences of whitespace into single space in AddTags (#1840) 2022-05-07 09:16:57 +10:00
Henrik Giesel
1ec227d926
Make TagAddButton focusable and simulate click on focus (#1838) 2022-05-07 09:15:58 +10:00
Damien Elmes
c8a4e5ea22 Add more progress + abort points to export code
The old `media_files_did_export` hook has been kept around for use with
the legacy apkg exporter (an add-on uses it), and a new 
`legacy_export_progress` hook has been added so we can get progress
from the new colpkg exporter until we move over fully to the new code.
2022-05-06 15:32:23 +10:00
Damien Elmes
228b4331c3 Update translations 2022-05-06 09:27:15 +10:00
RumovZ
99c4ec93d2
Fix some apkg import issues (#1836)
* Allow gathering of orphaned decks

* Skip redundant media checking in apkg import
2022-05-06 09:22:15 +10:00
Damien Elmes
6a95141fd9 Accept .zip as an alias for .apkg
The legacy importer does this already, because some web servers and
clients sniff the content type of .apkg files, and "helpfully" rename
them to .zip
2022-05-05 21:25:59 +10:00
Damien Elmes
72389b97be Show a user-facing message instead of a traceback on invalid file type
While our importing dialog limits the types of files that can be selected,
users can also import by providing a filename on the command line.
2022-05-05 21:24:12 +10:00