Commit graph

22 commits

Author SHA1 Message Date
wackbyte
89833189a3 Reduce use of type casting (#3723) 2025-01-12 20:05:05 +11:00
RumovZ
0239f79c53 Svg icon (#3135)
* Add sveltekit-svg plugin to fix svg icon styling

Closes #3127.

* Unify svg icon usage

Moves all icons into ts/lib/components/icons.ts and uses a single component to render
them both with eslint and svelte-kit.

* Fix spinning revert icon not being centered

* Use svg earth icon for global label

* Add tooltip to global label icon

* Remove eslint-plugin-simple-import-sort

Imports are already sorted by dprint with conflicting rules.
2024-04-24 02:37:31 +01:00
Damien Elmes
57ff1097e4 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
991a69a3bb Reveal cloze answers in MathJax preview
Closes #1862
2022-05-19 12:48:12 +10:00
Henrik Giesel
da9e444cd3 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
Henrik Giesel
b55dae8834 Change sequence of Mathjax escaping (#1854) 2022-05-10 11:54:06 +10:00
Damien Elmes
604ed78de4 Fix &amp; showing up in MathJax
https://forums.ankiweb.net/t/anki-2-1-52-release-candidate/19412/22

Accidentally introduced in #1818
2022-05-03 14:21:31 +10:00
Henrik Giesel
2552b16f19 Instead of transforming to {\lt}, transform to &lt; (#1818)
* Instead of transforming to {\lt}, transform to &lt;

- In Mathjax editor
- This way you can also use Mathjax convenience shortcuts like <=> in
  chemistry mode: \ce{<=>}

* Remove unused translateEntitiesToMathjax() (dae)

https://github.com/ankitects/anki/pull/1818#discussion_r857238310
2022-04-25 13:42:54 +10:00
Henrik Giesel
1d77c10b3d Use trailingComma: all setting in .prettierrc (#1435) 2021-10-19 09:06:00 +10:00
Henrik Giesel
66608b06b0 Allow for explicit any 2021-09-17 21:30:32 +02:00
Henrik Giesel
159e932f79 Wrap Mathjax compilation into try/catch 2021-09-16 14:31:20 +02:00
Henrik Giesel
970a5f008b Focus on mount when using Mathjax shortcuts 2021-09-15 13:45:17 +02:00
Henrik Giesel
32bdf0f242 Fix alignment of empty icon 2021-09-15 13:43:37 +02:00
Henrik Giesel
eb2c81c79f Refactor editable/mathjax.ts 2021-09-15 13:33:25 +02:00
Henrik Giesel
6c0e649c79 Set color of Mathjax depending on nightMode 2021-09-15 13:33:24 +02:00
Henrik Giesel
befdbf2563 Move wrap to lib to allow editable to use it 2021-09-15 13:33:24 +02:00
Henrik Giesel
542c6965fb Show title on mathjax image 2021-09-15 13:33:22 +02:00
Henrik Giesel
c273084243 Display error Mathjax correctly 2021-09-15 13:33:22 +02:00
Henrik Giesel
5ddbcab636 Show math icon if Mathjax is empty 2021-09-15 13:33:22 +02:00
Henrik Giesel
2787d7e7fd Unify anki-mathjax-* to just anki-mathjax 2021-09-15 13:32:32 +02:00
Henrik Giesel
7255312ec5 Nicely portray mathjax with right color + alignment in Editor 2021-09-15 13:32:31 +02:00
Henrik Giesel
49d2dd6660 Implement MathjaxBlock 2021-09-15 13:32:30 +02:00