Commit Graph

1385 Commits

Author SHA1 Message Date
Damien Elmes
046c6c55d3 use extra rootDir in tsconfig instead of symlinks
The nice thing about the symlink approach is that it allowed tsc -b
to function without any changes to the tsconfig.json file, but it meant
there were extra links we had to maintain. So instead, we just add an
extra rootDirs entry, and add two commented-out lines that can be
uncommented when wanting to build with tsc directly.
2021-10-01 18:36:52 +10:00
Damien Elmes
e9d71bfbe4 yarn upgrade --latest
bootstrap still held back
2021-10-01 12:52:53 +10:00
Damien Elmes
a3d9f90af5 update to latest rules_nodejs & switch to ts_project
ts_library() is deprecated and will presumably be dropped from a
future rules_nodejs, and it wasn't working with the jest tests
after updating, so we switch over to ts_project().

There are some downsides:

- It's a bit slower, as the worker mode doesn't appear to function
at the moment.
- Getting it working with a mix of source files and generated files
was quite tricky, especially as things behave differently on Windows,
and differently when editing with VS Code. Solved with a small patch
to the rules, and a wrapper script that copies everything into the
bin folder first. To keep VS Code working correctly as well, the built
files are symlinked into the source folder.
- TS libraries are not implicitly linked to node_modules, so they
can't be imported with an absolute name like "lib/proto" - we need
to use relative paths like "../lib/proto" instead. Adjusting "paths"
in tsconfig.json makes it work for TS compilation, but then it fails
at the esbuild stage. We could resolve it by wrapping the TS
libraries in a subsequent js_library() call, but that has the downside
of losing the transient dependencies, meaning they need to be listed
again.  Alternatively we might be able to solve it in the future by
adjusting esbuild, but for now the paths have been made relative to
keep things simple.

Upsides:

- Along with updates to the Svelte tooling, Svelte typing has improved.
All exports made in a Svelte file are now visible to other files that
import them, and we no longer rebuild the Svelte files when TS files
are updated, as the Svelte files do no type checking themselves, and
are just a simple transpilation. Svelte-check now works on Windows again,
and there should be no errors when editing in VS Code after you've
built the project. The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.
- Each subfolder now has its own tsconfig.json, and tsc can be called
directly for testing purposes (but beware it will place build products
in the source tree): ts/node_modules/.bin/tsc -b ts
- We can drop the custom esbuild_toolchain, as it's included in the
latest rules_nodejs.

Other changes:

- "image_module_support" is moved into lib/, and imported with
<reference types=...>
- Images are now imported directly from their npm package; the
extra copy step has been removed.

Windows users may need to use "bazel clean" before building this,
due to old files lying around in the build folder.
2021-10-01 12:52:53 +10:00
Damien Elmes
e46ca4ee54 update svelte-check
Invoking from scripts/svelte-check is currently broken due to sass
imports - it appears to have been broken some time back.
2021-09-29 12:27:27 +10:00
Damien Elmes
604247482d handle changed aria-expanded typing 2021-09-29 12:20:27 +10:00
Damien Elmes
d44b49294b make 'for' argument optional in TooltipLabel
The latest svelte-check has revealed we were not passing 'for' in
when we should have been. This is a quick hack to get the tests passing
again, but a better approach that actually makes this accessible again
would be good in the future.
2021-09-29 12:20:03 +10:00
Damien Elmes
04ba24cb54 silence execCommand deprecation warnings for now 2021-09-29 11:36:37 +10:00
Damien Elmes
e660e0a3e5 update svelte2tsx
We can now use the typings from the Svelte library instead of the
svelte2tsx shims
2021-09-25 11:07:31 +10:00
Damien Elmes
dc20300794 update to TypeScript 4.4.x 2021-09-23 09:53:37 +10:00
Damien Elmes
82f1cda09a fixes for TypeScript 4.4.x
closes #1386
2021-09-23 09:52:21 +10:00
Damien Elmes
94c4f99343 update ts deps
typescript and bootstrap have been pinned for now:

https://github.com/ankitects/anki/issues/1386
https://github.com/ankitects/anki/issues/1385

hint failures for svelte-check have also been temporarily turned
off, due to it now complaining about document.execCommand():

Hint: The signature '(commandId: string, showUI?: boolean, value?: string): boolean' of 'document.execCommand' is deprecated. (ts)
    const wrapWithForecolor = (color: string) => () => {
        document.execCommand("forecolor", false, color);
    };

Will follow up in #1377
2021-09-22 23:21:39 +10:00
Henrik Giesel
3f1da03615 Allow for explicit any 2021-09-17 21:30:32 +02:00
Henrik Giesel
51c0cedaf5 Make HandleSelection perfectly size when first activating 2021-09-17 21:23:04 +02:00
Henrik Giesel
06d1ec6af4 Fix missizing of HandleSelection when first moving from empty to Mathjax 2021-09-17 20:54:37 +02:00
Henrik Giesel
88fd31a099 Ugly fix: do not execute moveCursorPastPostfix when front includes "anki-mathjax" 2021-09-17 20:12:11 +02:00
Henrik Giesel
c30ba6a3f6 Add ChangeTimer.prototype.fireImmediately
so Mathjax is saved when exiting editor prematurely
2021-09-16 14:47:05 +02:00
Henrik Giesel
a1dde7c966 Wrap Mathjax compilation into try/catch 2021-09-16 14:31:20 +02:00
Henrik Giesel
60690e0557 Rename StickyBar and StickyBottom to StickyHeader and StickyFooter 2021-09-15 23:15:55 +02:00
Henrik Giesel
896b40c873 Remove now unused import in TagEditor 2021-09-15 22:59:47 +02:00
Henrik Giesel
9f56d51811 Fix suggestions not showing when typing space in a TagInput 2021-09-15 22:54:53 +02:00
Henrik Giesel
b502ceedca Make the ImageHandle and MathjaxHandle dropdowns perfectly touch the HandleSelection 2021-09-15 22:26:32 +02:00
Henrik Giesel
1f09402066 Stop propagation for paste in MathjaxHandle editor 2021-09-15 22:14:38 +02:00
Henrik Giesel
97647e7b24 Prevent hiding handles by clicking on handles 2021-09-15 17:56:56 +02:00
Henrik Giesel
9001b597da Remove style attribute after remove float property if not styling left 2021-09-15 17:36:48 +02:00
Henrik Giesel
9b7ea75399 Always correctly update MathjaxHandle position 2021-09-15 17:05:43 +02:00
Henrik Giesel
ce9674f824 Correctly pass down dropdownObject... 2021-09-15 16:16:42 +02:00
Henrik Giesel
7c6f6533c1 Using dropdownApi is much less faulty than using dropdownObject
- Update MathjaxSelection and Dropdown more reliably
2021-09-15 15:52:56 +02:00
Henrik Giesel
c227c7dc39 Make StickyBottom actually stick and make editor fullsize + flexbox 2021-09-15 15:21:37 +02:00
Henrik Giesel
c46f39c88e Import saveField from editor/saving.ts 2021-09-15 14:09:25 +02:00
Henrik Giesel
54b6491ce3 Remove duplicate outline:none 2021-09-15 13:46:07 +02:00
Henrik Giesel
71bdeeba39 Apply specific CSS to Mathjax CodeMirror 2021-09-15 13:46:04 +02:00
Henrik Giesel
219557afda Satisfy eslint 2021-09-15 13:45:20 +02:00
Henrik Giesel
ec9b43d3ab Use editorfield instead of editor-field 2021-09-15 13:45:20 +02:00
Henrik Giesel
c8c9c64ea5 Vertically center inline Mathjax 2021-09-15 13:45:20 +02:00
Henrik Giesel
c02973a85d Generalize accesing anki-mathjax from image in MathjaxHandle 2021-09-15 13:45:20 +02:00
Henrik Giesel
b6bea18b22 Add copyright header to saving.ts 2021-09-15 13:45:20 +02:00
Henrik Giesel
09819d4e7d Satisfy eslint 2021-09-15 13:45:19 +02:00
Henrik Giesel
e269fe73da Define CodeMirror in external codeMirror.ts 2021-09-15 13:45:19 +02:00
Henrik Giesel
e71aed7146 Correctly import CodeMirror 2021-09-15 13:45:19 +02:00
Henrik Giesel
a3fef552bd Include codemirror libs for svelte 2021-09-15 13:45:19 +02:00
Henrik Giesel
c663785264 Satisfy eslint 2021-09-15 13:45:19 +02:00
Henrik Giesel
111d34c17b Remove empty constructor 2021-09-15 13:45:19 +02:00
Henrik Giesel
e06ff2ae3c Focus on mount when using Mathjax shortcuts 2021-09-15 13:45:17 +02:00
Henrik Giesel
af556c391d Fix alignment of empty icon 2021-09-15 13:43:37 +02:00
Henrik Giesel
de056fbd89 Change Wrap commands / shortcuts to use anki-mathjax 2021-09-15 13:42:36 +02:00
Henrik Giesel
c3f56ad5cd Refactor editable/mathjax.ts 2021-09-15 13:33:25 +02:00
Henrik Giesel
45d0cc49e6 Set fixed fontSizef or mathjax in editor for now 2021-09-15 13:33:25 +02:00
Henrik Giesel
b5900da0b4 Set color of Mathjax depending on nightMode 2021-09-15 13:33:24 +02:00
Henrik Giesel
6856850a0f Wrap Mathjax buttons into toolbar 2021-09-15 13:33:24 +02:00
Henrik Giesel
f76cf24e9d Move wrap to lib to allow editable to use it 2021-09-15 13:33:24 +02:00