Commit Graph

768 Commits

Author SHA1 Message Date
Henrik Giesel
8760bd9ac6 Add theming support for DropdownItem and DropdownMenu 2021-04-15 13:09:50 +02:00
Henrik Giesel
49daa2dd01 Improve looks of color picker button 2021-04-15 13:09:50 +02:00
Henrik Giesel
02c8893fc9 Update CSS for ColorPicker and forecolor button 2021-04-15 13:09:50 +02:00
Henrik Giesel
9f740f307d Switch from core to base CSS for editor view 2021-04-15 13:09:50 +02:00
Henrik Giesel
0133652d04 Correctly check for night mode 2021-04-15 13:09:50 +02:00
Henrik Giesel
d6d4269aaf Rely more heavily on bootstrap provided types for editor-toolbar 2021-04-15 13:09:50 +02:00
Henrik Giesel
e6996ae5d3 Make mdi also use renamed pkg_from_name 2021-04-15 13:09:50 +02:00
Henrik Giesel
443cef6b15 Add buttons_mixins.scss for sharing SCSS across components 2021-04-15 13:09:50 +02:00
Henrik Giesel
00d8d869f4 Also add Bootstrap buttons.scss 2021-04-15 13:09:50 +02:00
Henrik Giesel
8f7c32fcf9 Include Dropdown directly from bootstrap, required installing popperjs 2021-04-15 13:09:50 +02:00
Henrik Giesel
38cc0dfce5 Use compile_sass and add flag to make editor-toolbar compile again 2021-04-15 13:09:50 +02:00
Henrik Giesel
1eafa7d9d0 Remove $$restProps and make explicit dropdown support in buttons
* Currently LabelButton, CommandIconButtton, and IconButton support dropdowns
2021-04-15 13:09:50 +02:00
Henrik Giesel
920b740c8f Add RawButton and hook old python hooks up to it 2021-04-15 13:09:50 +02:00
Henrik Giesel
432e0a5079 Introduce ToolbarItem as a better base type instead of DynamicSvelteComponent 2021-04-15 13:09:50 +02:00
Henrik Giesel
b364ae5542 Switch from lazy loading of properties to wrapping the buttons in a function 2021-04-15 13:09:50 +02:00
Henrik Giesel
d6ad5084f1 Add a button / buttonGroup insertion API 2021-04-15 13:09:50 +02:00
Henrik Giesel
8fd21661b4 Fix sticky toolbar which was broken when introducing var(--toolbar-size) 2021-04-15 13:09:50 +02:00
Henrik Giesel
eceb98f8e6 Show/Hide Cloze button depending on whether cloze type 2021-04-15 13:09:50 +02:00
Henrik Giesel
fe4ba87490 Move cloze logic and wrapping logic editor-toolbar 2021-04-15 13:09:50 +02:00
Henrik Giesel
cbf72c0f05 Make buttons and button groups easily toggleable through hidden web component 2021-04-15 13:09:50 +02:00
Henrik Giesel
4c273caedb Remove props property in favor of $$restProps 2021-04-15 13:09:50 +02:00
Henrik Giesel
f88b9d64d3 Get rid of types.d.ts in favor of DynamicSvelteComponent 2021-04-15 13:09:50 +02:00
Henrik Giesel
86c57d5b75 Pass button groups as actual button groups, not arrays 2021-04-15 13:09:50 +02:00
Henrik Giesel
d3e1bfa841 Pass wraps more similiar to how size is passed via CSS variables 2021-04-15 13:09:50 +02:00
Henrik Giesel
59884df70b Make wraps a passable prop to EditorToolbar
Can be set to nowrap via document.getElementByID("editorToolbar").component.$set({ wraps: false })
2021-04-15 13:09:50 +02:00
Henrik Giesel
bf33397855 Give clearer type names to dynamicComponent 2021-04-15 13:09:50 +02:00
Henrik Giesel
a2d37206ea Rename title to tooltip across editor toolbar components 2021-04-15 13:09:50 +02:00
Henrik Giesel
8e1092d2c4 Rename types.ts to types.d.ts 2021-04-15 13:09:50 +02:00
Henrik Giesel
120e1452e3 Change overflow of button groups to overflow-y auto
Avoids erratic creation of scrollbars
2021-04-15 13:09:50 +02:00
Henrik Giesel
c7590c8ef1 Use dynamicComponent instead of withLazyProps 2021-04-15 13:09:50 +02:00
Henrik Giesel
28201670ee Move enabled/disabled logic to EditorToolbar 2021-04-15 13:09:50 +02:00
Henrik Giesel
2046b00c38 Fix clicking the bold button immediately showing the updated button state
- rather than only after typing
2021-04-15 13:09:49 +02:00
Henrik Giesel
bb64f73c1a Support building as external repo 2021-04-15 13:09:49 +02:00
Henrik Giesel
10952de3c5 Remove lazyProperties -> we use withLazyProperties instead 2021-04-15 13:09:49 +02:00
Henrik Giesel
37ed3e8209 Fix some code quality issues 2021-04-15 13:09:49 +02:00
Henrik Giesel
96feba7a3e Pass in buttons and menus directly as stores 2021-04-15 13:09:49 +02:00
Henrik Giesel
8b906100c0 Make --toolbar-size a parameter 2021-04-15 13:09:49 +02:00
Henrik Giesel
9cbab08b00 Add ButtonDropdown for dropdowns like the MathJax dropdown on AnkiMobile 2021-04-15 13:09:49 +02:00
Henrik Giesel
6953389798 Add exports for add-ons 2021-04-15 13:09:49 +02:00
Henrik Giesel
45992b68cd Make it easier to update buttons and menus 2021-04-15 13:09:49 +02:00
Henrik Giesel
7f42b38e7a Add labels and titles to all buttons 2021-04-15 13:09:49 +02:00
Henrik Giesel
216b93c060 Add titles to buttons with lazyProperties 2021-04-15 13:09:49 +02:00
Henrik Giesel
4e6d5d9adb Move logic from index.ts to their individual files 2021-04-15 13:09:49 +02:00
Henrik Giesel
3ddbc1e6c3 Add first lazily loaded i18n strings 2021-04-15 13:09:49 +02:00
Henrik Giesel
9b68a5c2c3 Give select an effect on :hover 2021-04-15 13:09:49 +02:00
Henrik Giesel
5f498e6142 Make select display inline-block 2021-04-15 13:09:49 +02:00
Henrik Giesel
fb668c56e6 Make Toolbar resizable through a single CSS variable --toolbar-size 2021-04-15 13:09:49 +02:00
Henrik Giesel
f526b51ea2 Add SelectButton 2021-04-15 13:09:49 +02:00
Henrik Giesel
fa900e1565 Add dropdown menu to mathjax button 2021-04-15 13:09:49 +02:00
Henrik Giesel
391f64f648 Make it so you can include DropdownMenus on all kinds of buttons 2021-04-15 13:09:49 +02:00
Henrik Giesel
5eb07d3fc7 WIP: Turn DropdownMenu into a _decorator_ usable with all other button types 2021-04-15 13:09:49 +02:00
Henrik Giesel
a820059b8f Utilize enableButtons disableButtons from Svelte component 2021-04-15 13:09:49 +02:00
Henrik Giesel
9340d20c20 Display .active:active as :hover buttons 2021-04-15 13:09:49 +02:00
Henrik Giesel
4280bf28f8 Add active shadow on ColorPicker 2021-04-15 13:09:49 +02:00
Henrik Giesel
e25583d7ff Move display:flex from outer div to ButtonGroup ul 2021-04-15 13:09:49 +02:00
Henrik Giesel
7f5e9b1b33 Add negative tabindex 2021-04-15 13:09:49 +02:00
Henrik Giesel
b5b9c79f1c Add mathjaxButton and htmlButton instead of more button 2021-04-15 13:09:49 +02:00
Henrik Giesel
77de6c0288 Make icons slightly smaller, so they are the same size as before 2021-04-15 13:09:49 +02:00
Henrik Giesel
12021228a5 Make all buttons functional 2021-04-15 13:09:49 +02:00
Henrik Giesel
2f808fe60c Move initialization logic from EditorToolbar to index.ts 2021-04-15 13:09:49 +02:00
Henrik Giesel
bf433f13be Simplify General Toolbar structure 2021-04-15 13:09:49 +02:00
Henrik Giesel
773f431bb8 Merge buttons to one OuterButtonGroup
- keeping up the concept of left / right buttons might not be necessary anymore
- This might make it easier to display them on mobile, and simplifies the logic
2021-04-15 13:09:49 +02:00
Henrik Giesel
8c931af17c Make all Leaf buttons 30px high and give same vertical-align 2021-04-15 13:09:49 +02:00
Henrik Giesel
0269c97b2e Rename IconButtonInner to InnerButton, as it does not necessarily contain an Icon 2021-04-15 13:09:49 +02:00
Henrik Giesel
a12e39a15f Add hover and active effects 2021-04-15 13:09:49 +02:00
Henrik Giesel
b26c4294ec Display ButtonGroups inline-block 2021-04-15 13:09:49 +02:00
Henrik Giesel
9563da37d3 Add ButtonGroup for grouping of toolbar items 2021-04-15 13:09:49 +02:00
Henrik Giesel
ccb7c5d68a Add CommandIconButton functionality 2021-04-15 13:09:49 +02:00
Henrik Giesel
0963d53e0c Add color.ts for foreground color and color picker 2021-04-15 13:09:49 +02:00
Henrik Giesel
fee78d2570 Add remaining icons for toolbar 2021-04-15 13:09:49 +02:00
Henrik Giesel
a0a9619722 Include icons directly in ts lib 2021-04-15 13:09:49 +02:00
Henrik Giesel
7787a7827f First implementation 2021-04-15 13:09:48 +02:00
Henrik Giesel
de77e40e4d Add ts/editor-toolbar 2021-04-15 13:09:48 +02:00
Damien Elmes
6f3e682c9f move bootstrap into ts/sass 2021-04-15 16:10:01 +10:00
Damien Elmes
b0206ec1bf support external building of sass; node_modules->ts/bootstrap 2021-04-15 15:59:17 +10:00
Damien Elmes
6cee43631a allow passing sass deps to svelte compile/check 2021-04-15 14:27:53 +10:00
Damien Elmes
2d417b1160 update other ts deps 2021-04-15 10:59:29 +10:00
Damien Elmes
121e8db22a remove unused esbuild package, and update rules_nodejs packages 2021-04-15 10:57:19 +10:00
Damien Elmes
13d415f8e3 move esbuild into separate repo
Most of our changes have been upstreamed, but the toolchain change
probably won't be merged soon, and a separate git repo will make it
easier to track upstream changes.

@hgiesel output_css=True will need to be changed to output_css="foo.css"
instead
2021-04-15 10:53:49 +10:00
Damien Elmes
b9b1fe81b1 fix initial ease not being updated 2021-04-14 23:01:03 +10:00
Damien Elmes
7f738c11a2 deck config prototype work in progress
Still in the early stages, and not hooked up yet.
2021-04-14 22:33:10 +10:00
Damien Elmes
e6306bb29d
Merge pull request #1128 from hgiesel/webviewcss3
Remove unnecessary exports from sass/BUILD.bazel
2021-04-14 21:28:25 +10:00
Damien Elmes
646b58a1a9 experiment with making bootstrap scss available as a library
This will allow us to import the local sass lib, then use something
like the following in our sass:

@import "ts/bootstrap/functions";
@import "ts/bootstrap/variables";
@import "ts/bootstrap/mixins";
@import "ts/bootstrap/helpers";
@import "ts/bootstrap/dropdown";
@import "ts/bootstrap/forms";
@import "ts/bootstrap/buttons";
@import "ts/bootstrap/button-group";
 
I'm currently trialing it out on a prototype reimplementation of the
deck options screen. Unfortunately bootstrap don't seem to support the
@use syntax, so we need to @import everything
2021-04-14 21:27:34 +10:00
Henrik Giesel
a9439eaf02 Remove unnecessary exports from sass/BUILD.bazel
I think these were just part of an unsuccessful experiment
Partially reverses cfb9ed267f
2021-04-14 12:31:42 +02:00
Damien Elmes
cca9195ea5 run prettier on some sass files 2021-04-14 18:22:33 +10:00
Damien Elmes
c49d6ce49f run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
7b2b4528b3
Merge pull request #1125 from hgiesel/scrollbarcorner
Color Scrollbar bottom right corner
2021-04-14 12:43:34 +10:00
Henrik Giesel
f891a98087 Color in the Scrollbar corner at the bottom right into the appropriate color 2021-04-13 21:41:15 +02:00
Henrik Giesel
cfb9ed267f Create explicit dependencies for the congrats,editor,graphs scss files 2021-04-13 19:47:03 +02:00
Henrik Giesel
a76f1d64ad Move compile_sass.bzl to /ts + Remove core.css from data/web (unused?) 2021-04-13 19:47:03 +02:00
Henrik Giesel
ffd159f9a0 Declare dependencies in data/web/css 2021-04-13 19:47:03 +02:00
Henrik Giesel
85808e4cbf Make h1 explicitly bold in Graph.svelte 2021-04-13 19:47:03 +02:00
Henrik Giesel
8f0f8f9af8 Use graphs-base and congrats-base 2021-04-13 19:47:03 +02:00
Henrik Giesel
fee6ee7319 Do not include webview.css for editor 2021-04-13 19:47:03 +02:00
Henrik Giesel
825509ba0c Move card_counts and split off fusion_vars 2021-04-13 19:47:03 +02:00
Henrik Giesel
fbc21f0090 Add base.scss 2021-04-13 19:47:03 +02:00
Damien Elmes
62423bd041 add missing copyright headers to *.svelte 2021-04-13 19:02:41 +10:00
Damien Elmes
e520e8df02 add missing copyright headers to *.ts 2021-04-13 18:57:08 +10:00
Damien Elmes
26ac64526c disable Jest tests on Windows again
It looks like the templated_args change only masked the error last time;
Jest seems broken on Windows with both the patched .24 version, latest
stable, and the new beta version too, presumably because symlinks are
being handled differently on Windows somehow. It might be possible to
hack around the issue by patching the following file, but I'm not sure:

https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/crawlers/node.ts
2021-04-12 15:39:46 +10:00
Damien Elmes
9440898e60 add naturalWholeUnit() and basic tests to lib/time.ts
naturalWholeUnit() is not currently used
2021-04-12 14:42:06 +10:00
Damien Elmes
829b99e5b2 force number in protobuf generation
Anki's object IDs and millisecond timestamps fit within MAX_SAFE_INTEGER.
2021-04-12 14:33:20 +10:00
Damien Elmes
6e4cdc52a6 stop Svelte warnings from failing the build
+ check for them at test time
2021-04-12 14:28:09 +10:00
Damien Elmes
94330fc0eb fix jest
- templated_args was missing --node_modules= prefix, and was causing
tests to pass unconditionally
- update to beta of jest 27, which introduces an option to fix the
symlink handling, and is approx twice as fast to start up
2021-04-12 09:43:31 +10:00
Damien Elmes
c1c14419a2 switch esbuild to a toolchain 2021-04-07 15:19:23 +10:00
Damien Elmes
4975f47ea3 update to latest esbuild 2021-04-07 14:54:40 +10:00
abdo
09985ce57f Fix graph labels display in RTL layout 2021-04-02 06:25:38 +03:00
Damien Elmes
ddcb2adf71 add docstring to forEditorField 2021-03-29 18:13:45 +10:00
Damien Elmes
0e4bcbd69b
Merge pull request #1101 from Arthur-Milchior/TS_type
NF: add type ts
2021-03-29 18:09:56 +10:00
Damien Elmes
f1780e6e24 move loader arg into esbuild() invocation
upstream.bzl should be kept as close to upstream as possible, so that
it's easier to send changes upstream and pull in future changes
2021-03-29 17:59:06 +10:00
Arthur Milchior
a114f36b4c NF: add type ts 2021-03-28 23:59:16 +02:00
Henrik Giesel
922ee56ce8 Add copy_bootstrap_icons macro 2021-03-28 18:50:37 +02:00
Henrik Giesel
7dcb3ae678 Include pin-angle icon via inline SVG 2021-03-28 16:15:30 +02:00
Damien Elmes
dbfbcc36c6 define file extension in .d.ts so typescript doesn't complain 2021-03-28 16:15:28 +02:00
Henrik Giesel
3a44ffe2bb Unsuccessfully try to add text loader for .svg files 2021-03-28 16:14:52 +02:00
Henrik Giesel
bbea9ac9d7 Remove bootstrap-icons from css folder 2021-03-28 16:14:52 +02:00
Damien Elmes
0d49b3eabb move back to latest Jest
Patch is no longer required after previous change
2021-03-28 21:44:55 +10:00
Damien Elmes
493557aee7 fix Jest on Windows 2021-03-28 20:59:51 +10:00
Damien Elmes
f46f4cbf17 Revert "disable Jest tests on Windows for now"
This reverts commit 36022844bb.
2021-03-28 20:59:31 +10:00
Damien Elmes
36022844bb disable Jest tests on Windows for now 2021-03-28 20:34:10 +10:00
Damien Elmes
c891f45ed9 add Jest for TS unit tests
@hgiesel the reason no files were being found is because Jest ignores
symlinks by default. The Bazel example includes a patch we can use
to work around it, and Jest plan to add symlink support in a future
update.

https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/jest/patches/jest-haste-map%2B24.9.0.patch

https://github.com/facebook/jest/pull/9351
2021-03-28 19:41:20 +10:00
Henrik Giesel
05ea624f85 Utilize ts/tsconfig.js from ts/{editor,html-filter} 2021-03-28 19:41:20 +10:00
Henrik Giesel
fb9461508e No need to explicitly import from index 2021-03-28 19:41:20 +10:00
Henrik Giesel
35beebcfa6 Satisfy formatter 2021-03-28 19:41:20 +10:00
Henrik Giesel
861c723ec0 Avoid using outerHTML + Fix regression 2021-03-28 19:41:20 +10:00
Henrik Giesel
f9259621a6 Change filter logic in html-filter/element: predicate true, means it stays in 2021-03-28 19:41:20 +10:00
Henrik Giesel
519aea2ea8 Move html-filter into its own directory 2021-03-28 19:41:20 +10:00
Henrik Giesel
730dfdd527 Insert break statements into switch 2021-03-28 19:41:20 +10:00
Henrik Giesel
39aa549ac9 Create htmlFilter{Node,Styling} for better separation of concerns 2021-03-28 19:41:20 +10:00
Henrik Giesel
d3d3720b39 Put filterElement logic completely into its own file 2021-03-28 19:41:20 +10:00
Henrik Giesel
1d4d7fabec Move most of tags allowed to its own file 2021-03-28 19:41:20 +10:00
Henrik Giesel
592d73c344 Refactor htmlFilter to use function declarations 2021-03-28 19:41:20 +10:00
Damien Elmes
76127126a6 use relative link to sass file
links relative to workspace root break when invoked from an external
repo
2021-03-28 12:37:21 +10:00
Damien Elmes
f3a3bb5467 add links to pending PRs 2021-03-28 12:32:40 +10:00
Damien Elmes
559d1a4793 fix(esbuild): files not being found when building external repo
An esbuild rule that ran fine in a local repo (eg bazel build //:my_esbuild_rule)
fails when built externally (eg bazel build @other_workspace//:my_esbuild_rule).
By prepending the workspace root to the bin path, the resulting base
URL works correctly in both local and remote repo invocations, allowing
esbuild output to be consumed by a different repo.

This change fixes remote repos in Bazel 4.0.0. 3.7.0 seems to require a
workspace_root.replace("external/", "") call first in order
to get the correct location. So while this patch should not break anything
that was not already broken, it only fixes/adds support for remote repos
in 4.0+.
2021-03-28 11:30:15 +10:00
Damien Elmes
08fd7a4747 add esbuild/helpers.bzl in from upstream 2021-03-28 11:12:23 +10:00
Damien Elmes
b23642d568 update $(location ...) in esbuild inject lines 2021-03-28 09:35:46 +10:00
Damien Elmes
944528d462 support expanding locations in esbuild arguments 2021-03-28 09:35:27 +10:00
Damien Elmes
fd324d4711 update TS deps 2021-03-27 15:02:02 +10:00
Damien Elmes
d2eb5c32f4 remove obsolete comment 2021-03-26 21:47:23 +10:00
Damien Elmes
b57e9be46f allow js to request specific i18n modules
Brings the payload on the congrats page with a non-English language
down from about 150k to 15k
2021-03-26 21:43:36 +10:00
Damien Elmes
8920a6f9ea fix handling of variables that don't match ts naming style 2021-03-26 21:34:24 +10:00
Damien Elmes
c039845c16 use singleton + free functions for i18n in ts
This allows for tree shaking, and reduces the congrats page from 150k
with the old enum solution to about 80k.
2021-03-26 20:38:44 +10:00
Damien Elmes
0de7ab87a5 drop legacy enum from ts/ 2021-03-26 19:26:35 +10:00
Damien Elmes
2e704660d6 update remaining TR references in ts/ 2021-03-26 19:24:48 +10:00
Damien Elmes
1ca25c563f update most no-arg TR references in *.svelte 2021-03-26 19:13:30 +10:00
Damien Elmes
cd4572c3dd update TR references with args in *.svelte 2021-03-26 19:13:30 +10:00
Damien Elmes
df93ed0b15 update TR references with args in *.ts; fix average answer time 2021-03-26 19:10:39 +10:00
Damien Elmes
b435658acb convert no-arg TR references to method invocations in *.ts 2021-03-26 19:10:27 +10:00
Damien Elmes
264b9204c0 generate ts methods for translations 2021-03-26 18:11:58 +10:00
Damien Elmes
9aece2a7b8 rework translation handling
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.

This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.

The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.

Other changes:

- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
2021-03-26 09:41:32 +10:00
Henrik Giesel
7655f14859 Satisfy svelte_check 2021-03-22 15:41:43 +01:00
Henrik Giesel
a418d36c7f Add type signatures to asyncReactive 2021-03-22 15:30:35 +01:00
Henrik Giesel
6ec721d550 Satisfy formatter 2021-03-22 15:25:49 +01:00
Henrik Giesel
4cd60da7b8 Fix asyncReactive detection of loading
- Removed `success` store as it wouldn't work
- We should check for a value in error instead
2021-03-22 15:23:48 +01:00
Henrik Giesel
e23b1b77b7 Partially revert "Make sure RangeBox does not trigger update on stores on creation"
This reverts commit 15b19e44b9.
2021-03-22 15:11:36 +01:00
Henrik Giesel
9bbdc616c4 Remove assignment to preferencesPromise: getPreferences will only be called once 2021-03-22 04:03:52 +01:00
Henrik Giesel
10b8a1c3cb Move async and asyncReactive to sveltelib
- sveltelib is a lib for component-agnostic svelte utils
2021-03-22 03:06:53 +01:00
Henrik Giesel
3c5233297a Avoid duplicate initial fetching with asyncReactive 2021-03-22 02:58:19 +01:00
Henrik Giesel
15b19e44b9 Make sure RangeBox does not trigger update on stores on creation 2021-03-22 02:50:16 +01:00
Henrik Giesel
0bbe38ebde Create search and days writable in GraphsPage to allow browserSearch to work 2021-03-22 02:44:08 +01:00
Henrik Giesel
9a864120b2 Fix syntax error introduced by rebase 2021-03-22 01:44:07 +01:00
Henrik Giesel
7dc74004ae Create BrowserSearch component, because we cannot read from stores within slotted content 2021-03-22 01:42:23 +01:00
Henrik Giesel
6d546b0bca Remove pending, and resort to checking for value
- once value is set, it won't be unset
2021-03-22 01:42:23 +01:00
Henrik Giesel
b3851172ba Use preferencesPromise, as refreshing is handled over stores 2021-03-22 01:42:23 +01:00
Henrik Giesel
3363c574c9 Use $-assignments instead of store.set 2021-03-22 01:42:23 +01:00
Henrik Giesel
dd2e180f9b Rename search and days to initialSearch and intitialDays in GraphsPage 2021-03-22 01:42:23 +01:00
Henrik Giesel
672eb20321 Get it to work, if you change the input
- there's still an issue on initial load
2021-03-22 01:42:23 +01:00
Henrik Giesel
3f37153558 Compiles with WithGraphData 2021-03-22 01:42:23 +01:00
Henrik Giesel
c107090906 Move Graph-specific html from GraphsPage to Graph.svelte 2021-03-22 01:42:21 +01:00
Henrik Giesel
36e14cd525 Add WithGraphData 2021-03-22 01:40:51 +01:00
Henrik Giesel
e11b31c29d Rename asyncRefresh to asyncReactive 2021-03-22 01:40:51 +01:00
Henrik Giesel
75a8b7d318 Improve implementation of asyncRefresh 2021-03-22 01:40:51 +01:00
Henrik Giesel
a9c16a3cd8 Add (probably non-working) asyncRefresh 2021-03-22 01:40:51 +01:00
Henrik Giesel
f82a02bd2e Add Svelte async hook 2021-03-22 01:40:51 +01:00
Henrik Giesel
5b9981e04a Add comment where to find global styles 2021-03-21 16:04:38 +01:00
Henrik Giesel
af307a6c4a Move ticks.scss directly into Graph.svelte 2021-03-21 15:59:11 +01:00
Damien Elmes
7d8f19e6e4 merge in Henrik's TS/Svelte refactor with some changes
- The previous commits moved the majority of the remaining global css
into components; move the remaining @emotion/css references into
ticks.scss and the styling of the Graph.svelte. This is not as elegant
as the emotion solution, but builds a whole lot faster, and most of
our styling can be scoped to a component anyway.
- Leave the .html files in ts/ for now. AnkiMobile uses them, and
AnkiDroid likely will in the future too. In the long run we'll likely
move to loading the JS into an existing page instead of loading a
separate page, but at that point we can just exclude the .html file from
copy_files_into_group() without affecting other clients.

Closes #1074
2021-03-21 23:01:18 +10:00
Damien Elmes
95ccfc1ed3 move some cumulative-overlay-specific styling out of shared css 2021-03-21 20:18:05 +10:00
Damien Elmes
9dc6e059f2 add HoverColumns.svelte for hoverzone styling 2021-03-21 19:58:39 +10:00
Damien Elmes
7bc41366e8 add CumulativeOverlay.svelte for area styling 2021-03-21 19:50:35 +10:00
Damien Elmes
6e12348cfd add Tooltip.svelte so we can encapsulating styling 2021-03-21 19:35:38 +10:00
Damien Elmes
dbe5d43ba0 bundle all Svelte css into separate file
- svelte compilation outputs a separate .css file for each component
- compilation also adds an "import foo.css" to the top of each generated
.mjs file
- when the .mjs files are bundled into app.js, esbuild creates an app.css
as well
- graphs.scss was renamed to graphs_shared.scss and imported in the
top level GraphsPage. Henrik's style refactoring would be a better path
forward, but I needed to make this change for now, as the filenames were
conflicting.
2021-03-21 16:06:36 +10:00
Damien Elmes
1e14384d88 add support for declaring css output in esbuild call 2021-03-21 16:06:36 +10:00
Damien Elmes
860ae5464c add upstream esbuild impl so we can add css output support
Taken from 4a26898023/packages/esbuild/esbuild.bzl
2021-03-21 16:06:36 +10:00
Damien Elmes
a581c082f6 switch from rollup to esbuild
brings the 2+ second bundle on a module like the graphs down to 90ms
2021-03-21 16:06:36 +10:00
Damien Elmes
5403f704d0 ESM import issue on Windows came back again
Not sure if I just missed this in the previous change, or whether
the patch_resolver change broke things again.

Previous issue:
e60eb27184
2021-03-21 16:06:07 +10:00
Damien Elmes
e857aa2ea9 output embedded Svelte css into separate .css file for bundling 2021-03-21 16:06:01 +10:00
Damien Elmes
2658d9992e fixes for Svelte compilation
- enable resolver patch on worker binary to ensure js imports work
on subsequent worker requests
- cache ts library content, and use unified interface for cache
- prepare for separate css outputs
2021-03-21 16:05:46 +10:00
Damien Elmes
e0b85865f4 avoid temporary .ts file due to lack of sandbox on Windows
Just a quick hack for now to store it in memory, as the temp file
conflicts on Windows due to the lack of a sandbox, and we don't really
have a need to write it to the filesystem anyway.
2021-03-21 00:17:09 +10:00
Damien Elmes
aabcc8a7db use ts language service for much faster Svelte compiles 2021-03-20 23:49:10 +10:00
Damien Elmes
554081cee3 convert svelte worker to ts
Should make it easier to maintain, and ironically it also fixes
the issue with .mjs files from this morning.
2021-03-20 23:13:27 +10:00
Damien Elmes
0cc06ad03b switch Svelte compilation to worker model
based on changes from upstream rules_svelte

Their code was using run_node() instead of ctx.actions.run(), which
seems to create a new worker for every CPU core, instead of respecting
the standard limit of 4.
2021-03-20 22:52:35 +10:00
Damien Elmes
8cfd28bd00 clarify comment 2021-03-20 16:25:50 +10:00
Damien Elmes
e60eb27184 update Svelte and fix Windows build
Svelte 3.25.0 and onwards bundle compiler.mjs, which seems to be
preferentially used over the .js file. Presumably this is only breaking
on Windows due to the lack of a sandbox. Resolve by explicitly requesting
the .js file.
2021-03-20 16:13:20 +10:00
Damien Elmes
ea7611d8cc vendor Svelte rules
The separate repo made it difficult to update the rules, and made things
more complicated than they needed to be.
2021-03-20 15:04:19 +10:00
Damien Elmes
1e57a753da update rules_nodejs 2021-03-20 10:54:18 +10:00
Damien Elmes
afc2892f2e move to new rules_nodejs protobuf example to unblock upgrade
@hgiesel the tag editor will need to add the following to the rollup
deps:

        "//ts/lib:backend_proto",
        "//ts/lib:fluent_proto",
2021-03-20 10:24:32 +10:00
Damien Elmes
30c7cf1fdd fade out webview when pending updates; do some reviewer updates immediately
Issues that need fixing:
- when the editor saves the note with perform_op(), if it isn't modified,
no new undo entry is created, and perform_op then returns the changes
made by the previous operation instead
- the approach of fetching the last action in a subsequent backend
method is unsound, as another queued operation may sneak in first before
we have a chance to query the result - it would be better if it were
returned in a single atomic action
- redrawing the current card while editing is likely to make sound
autoplay annoyingly, and it has an unpleasant redraw. We may be better off
fading it out instead

Side note: the editor cursor moves to the start of the field when the
note is updated in another window - it might be nicer to have it move
the cursor to the end instead.
2021-03-19 19:45:21 +10:00
Henrik Giesel
76102db2a9 Fix bug with initially enabled toolbar in browser 2021-03-10 19:28:08 +01:00
Henrik Giesel
2905881dcf Fix another import 2021-03-09 14:02:41 +01:00
Henrik Giesel
475b1968d0 Fix reversed sticky icon logic 2021-03-09 13:44:06 +01:00
Henrik Giesel
acb912697e Satisfy formatter 2021-03-09 13:43:11 +01:00
Henrik Giesel
b5362e99c0 Change to pin icon 2021-03-09 13:43:11 +01:00
Henrik Giesel
9e557bb0c1 Switch to bi-sticky icons, toggle opacity for state indiciation 2021-03-09 13:43:11 +01:00
Henrik Giesel
25d7d80e20 Switch back to pin icons, use fill/unfilled versions 2021-03-09 13:43:11 +01:00
Henrik Giesel
fee4667e32 Place sticky icons at the far right end of the labelContainer 2021-03-09 13:43:11 +01:00
Henrik Giesel
cd26901f3d Make sure topleft buttons are rounded too, prefer Bootstrap's rounded class 2021-03-09 13:43:11 +01:00
Henrik Giesel
da0317cb85 Replace pin icon with lock icon
Credit goes out to @kleinerpirat
2021-03-09 13:43:11 +01:00
Henrik Giesel
29742122d2 Remove button highlight on disabling button (i.e. blur) 2021-03-09 13:43:09 +01:00
Henrik Giesel
a8bde2d13c Remove "true" return value from event handler
* this does not change any semantics
2021-03-09 13:41:39 +01:00
Henrik Giesel
2f46c69ed6 Separate index.ts into editable/editingArea/editorField/labelContainer.ts 2021-03-09 13:40:47 +01:00
Henrik Giesel
8593ab3c4c Connect icons to sticky fields values 2021-03-09 13:37:56 +01:00
Henrik Giesel
d1bca9e4d9 Add visual elements for pinned fields 2021-03-09 13:37:56 +01:00
Henrik Giesel
d13bd1096d Remove explicit popperjs again, because it's included in bootstrap.bundle 2021-03-09 13:37:56 +01:00
Henrik Giesel
fb5763afb6 Change font-size in topbar buttons
Bootstrap sets font-size to inherit, so it's not inherited from top.
Before, it defaulted to 13, so this should prevent add-ons, which
feature text in their buttons (like <select> buttons).
2021-03-09 13:37:56 +01:00
Henrik Giesel
a66b0fbd84 Fix positioning of buttons 2021-03-09 13:37:56 +01:00
Henrik Giesel
81d1f2906a Fix highlight for topright buttons 2021-03-09 13:37:56 +01:00
Henrik Giesel
037539dbf4 Remove field margins
* Bootstrap solves it more elegantly with line-height
* body { margin: 0 } is also defined by bootstrap
2021-03-09 13:37:56 +01:00
Henrik Giesel
f2cc85a3bc Include bootstrap in editor 2021-03-09 13:37:56 +01:00
Henrik Giesel
aeda64a890 Add bootstrap, bootstrap-icons, and popperjs 2021-03-09 13:37:56 +01:00
Damien Elmes
7aac1b08d2
Merge pull request #1062 from abdnh/strip-html-comments
Strip HTML comments from external pastes
2021-03-09 11:55:59 +10:00
Damien Elmes
d3fa8621cb
Merge pull request #1060 from hgiesel/focusplus
Fix focus handling by moving caretToEnd logic
2021-03-09 11:53:09 +10:00
abdo
7673a52a02 Strip HTML comments from external pastes
Fix a regression caused by 150de7a683
2021-03-09 03:15:08 +03:00
Henrik Giesel
76260c3f8d Satisfy formatter 2021-03-08 20:55:04 +01:00
Henrik Giesel
972993b42e Move caretToEnd logic out of focus handling 2021-03-08 20:40:23 +01:00
Henrik Giesel
6db7897601 Improve focus handling
* Ported from #1046:

* disabling buttons will clear button highlight
* enabling button will set button highlight
* move caret to end executed before enabling buttons (so button highlight will be for actual position of caret)
* move caret to end will also be executed if previousActiveElement is null, which will only be the case before the first onBlur was executed:
  * so that caret will be moved to end on opening editor
2021-03-08 14:20:06 +01:00
abdo
79dcfc84be Fix editor RTL check 2021-03-07 18:12:42 +03:00
Henrik Giesel
aa3ba38392 Do not execute caretToEnd when Alt-tabbing back to application 2021-03-06 17:57:04 +01:00
Henrik Giesel
e36a9c78e3 Fix focus handling when coming from top left buttons 2021-03-01 12:28:45 +01:00
Damien Elmes
c9992e395f
Merge pull request #1038 from hgiesel/imgmaxwidth
Fix scrollbar issue in anki-editable component in two ways
2021-02-24 10:16:12 +10:00
Damien Elmes
8d7cd1992c
Merge pull request #1037 from hgiesel/browserbug2
Remove logic for pulling editor field into view
2021-02-24 09:53:11 +10: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
Henrik Giesel
9383002b0e Satisfy formatter 2021-02-23 13:34:41 +01:00
Henrik Giesel
5bb90aa8a5 Remove logic for pulling editor field in view 2021-02-23 12:55:04 +01:00
Henrik Giesel
ec9c623d34 Satisfy formatter 2021-02-22 14:44:31 +01:00
Henrik Giesel
3d4323b1d4 Load graphs.js from head
* Also move script into body, to be a valid HTML document
2021-02-22 14:17:56 +01:00
Henrik Giesel
aeb6de9166 Move tooltip creation into function 2021-02-22 14:10:35 +01:00
Henrik Giesel
b98ddaafaa Increase the padding in the editable to 6px 2021-02-16 18:40:58 +01:00
Henrik Giesel
cfa44025a8 Add max-width: 100% to editable.scss 2021-02-16 18:28:40 +01:00
Damien Elmes
402921dac7 ignore manually scheduled cards in hour graph 2021-02-10 09:36:51 +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
678a049d0e add missing license headers 2021-02-09 13:38:04 +10:00
Henrik Giesel
ee194e951c Rework focusing code to fix two issues:
1. Clicking away from the editor window, and back on it should not focus old field
2. Clicking on a field, which is not fully visible, should scroll it into view
2021-02-09 01:09:16 +01:00
Henrik Giesel
b56b3fd74a Use mouseup intead of click for updateButtonState 2021-02-08 22:18:06 +01:00
Henrik Giesel
a90931b91e Refactor wrap code 2021-02-08 22:13:49 +01:00
Henrik Giesel
d10383ea9d Give toolbar items a bottom margin to separate the rows when they wrap 2021-02-08 21:26:37 +01:00
Henrik Giesel
61c4ef40de Put wrapping code into its own file 2021-02-08 21:02:46 +01:00
Henrik Giesel
a19bc2d012 updateButtonState on clicking editor field 2021-02-08 20:49:33 +01:00
Henrik Giesel
bc7a1d12cd Export saveNow 2021-02-08 20:28:02 +01:00
Henrik Giesel
934a9bd24b Split up index.ts into several more files
This is to provide minimal closures for the mutable file-local variables:
- changeTimer
- previousActiveElement
- currentNoteId

This makes it clear, that they should not be used, but rather the
functions which wrap them in an API
2021-02-08 19:48:42 +01:00