Commit graph

1769 commits

Author SHA1 Message Date
Damien Elmes
d47b0657ff run buildifier/buildozer to tidy up BUILD files 2021-12-14 09:18:24 +10:00
Matthias Metelka
9adfcd0884 Reimplement "Show Duplicates" button in editor (#1550)
* Add "Show duplicates" to LabelContainer

* Avoid bubbling down the duplicate logic into EditorField

* Move duplicate link into its own slot

to center it between name/description and field-state.

* Revert "Move duplicate link into its own slot"

This reverts commit 3a4511042d.

* Justify dupes within FieldState

to achieve the same result as before while avoiding additional logic within EditorField.

Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>
2021-12-13 14:06:12 +10:00
Henrik Giesel
ea1946596c Add back wrap function (#1551)
* Remove surround from RichText and PlainText

* Export wrap
2021-12-13 14:00:35 +10:00
RumovZ
c411d699a9 Add shortcuts for list and indentation (#1546) 2021-12-10 17:54:31 +10:00
Matthias Metelka
086a3e674e Decrease button and tag size for Linux and Windows (#1532)
* Decrease button size for platforms other than Mac

* Refactor legacy button styles

* Restrict size of add-on icons
2021-12-06 19:01:15 +10:00
Henrik Giesel
5be046eacd Block {,max-}{width,height} from being copied (#1529) 2021-12-06 18:41:08 +10:00
Abdo
8e609818f9 Flip arrows of Bootstrap-styled <select>s for RTL langs (#1526)
* Flip arrows of Bootstrap-styled <select>s for RTL langs

* Use the dir attribute to set document direction

* Remove unused variable and fix use of CSS var
2021-12-06 18:40:26 +10:00
Hikaru Y
cacb49f81d Fix custom CSS not being applied to scrollbars in night mode (#1525) 2021-12-05 08:20:42 +10:00
Matthias Metelka
785f6a78fc Rename StickyNav to StickyHeader (#1524)
so as to not create false assumptions about its functionality.
2021-12-05 08:18:58 +10:00
Matthias Metelka
af5938c37b Align design of Change Notetype screen with rest of UI (#1522)
* Remove background and border from scrollArea

* Fix 1px of background text showing above template header on scroll

I couldn't figure out the reason for this "clipping" issue. What I tried:
- check HTML structure for any elements that might add extra padding/margin
- remove the 1px border of the header

* Adjust spacing to be more in line with rest of UI
2021-12-04 14:53:16 +10:00
Matthias Metelka
695ab0f193 Show downwards arrow on SelectButton (#1521)
* Show downwards arrow on SelectButton

The arrow wasn't showing because the button linear-gradient background overrides the background-image for the arrow.

Select can't have pseudo-elements, so I had to add an extra div.

* Remove height definition

to fix text cutting off on Windows.

* Hide default arrow in light theme

to keep consistency with dark theme, where the arrow has to be custom due to the button gradient.

* Use alternative approach to prevent text getting cropped

and add height definition back again.

Co-Authored-By: Hikaru Y. <47855854+hikaru-y@users.noreply.github.com>

* Adjust arrow position for rtl

Co-authored-by: Hikaru Y. <47855854+hikaru-y@users.noreply.github.com>
2021-12-04 08:08:20 +10:00
Henrik Giesel
b4772f47d1 Fix focus lost after adding note if non-sticky (#1523) 2021-12-03 21:41:12 +10:00
Damien Elmes
149819e5a1 update Node deps
TypeScript is currently pinned. Before updating to 4.5, we will likely
need to use --preserveValueImports in svelte.ts:
https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#preserve-value-imports

There's also an issue with missing types when importing from bootstrap
.js files that will need investigating.
2021-12-03 20:35:53 +10:00
Damien Elmes
66fa578d83 fix update-licenses.sh 2021-12-03 20:35:53 +10:00
Damien Elmes
714486c25b fix position showing as date in card stats
Fixes #1519
2021-12-02 16:10:29 +10:00
Matthias Metelka
834f09110e Add missing editorToolbar export (#1511) 2021-11-29 12:40:31 +10:00
RumovZ
54d39d1b3b Live theme changes (#1497)
* Allow theme change at runtime and add hook

* Save or restore default palette on theme change

* Update aqt widget styles on theme change

* styling fixes

- drop _light_palette, as default_palette serves the same purpose
- save default platform theme, and restore it when switching away
from nightmode
- update macOS light/dark mode on theme switch
- fix unreadable menus on Windows

* update night-mode classes on theme change

This is the easy part - CSS styling that uses standard_css or our
css variables should update automatically. The main remaining issue
is JS code that sets colors based on the theme at the time it's run -
eg the graph code, and the editor.

* switch night mode value on toggle

* expose current theme via a store; switch graphs to use it

https://github.com/ankitects/anki/issues/1471#issuecomment-972402492

* start using currentTheme in editor/components

This fixes basic editing - there are still components that need updating.

* add simple xcodeproj for code completion

* add helper to get currently-active system theme on macOS

* fix setCurrentTheme not being immediately available

* live update tag color

* style().name() doesn't work on Qt5

* automatic theme switching on Windows/Mac

* currentTheme -> pageTheme

* Replace `nightModeKey` with `pageTheme`

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-25 07:17:41 +10:00
Damien Elmes
63b34e0f0e prettier: don't depend on system node being available 2021-11-25 07:14:15 +10:00
Matthias Metelka
e2a30666e4 Change Notetype UI Rework (#1499)
* Enable access to old notetype name

* Set minimum height for ChangeNotetypeDialog

* Add bootstrap icons to change-notetype

* Move alert up and make it collapsible

* Tweak some CSS

- Add variables --sticky-bg and --sticky-border to StickyContainer
- Tweak base.css

* Add translatable string "(Nothing)"

* Rework ChangeNotetype screen

* Initially load option at newIndex and remaining options on focus

Optimization for big notetypes:
Should increase efficiency from O(n²) to O(n). Test on notetype with 500 templates shows significant improvement in load time (~10s down to ~1s).

* Try to satisfy rust test

* Change arrow direction depending on reading direction

+ add 0.5em top padding to main

* Create Alert.svelte

* Introduce CSS variable --pane-bg

* Revert "Initially load option at newIndex and remaining options on focus"

This reverts commit f42beee45c.

* Final cleanup

* Refine padding/gutter
2021-11-24 12:09:55 +10:00
Henrik Giesel
a1d6269d49 Fix some issues with new surround buttons (#1505)
* Add a store to indicate whether input trigger is active

Button state is then indicated by: caretIsInBold XOR boldTriggerActive

* Fix surrounding where normalization is tripped up by empty text nodes

* Add failing test for unsurrounding

* Fix failing test

* prohibitOverlapse does not need to be active, if aboveEnd is null

* Reinsert Italic and Underline button

* Refactor find-adjacent to use sum types

* Simplify return value of normalizeAdjacent
2021-11-24 10:33:14 +10:00
Henrik Giesel
e14ab90551 Fix Cloze button (#1504) 2021-11-24 10:25:24 +10:00
Henrik Giesel
0f17c32401 Mathjax editor improvements (#1502)
* Remove unnecessary stopPropagation of mathjax-overlay events

* Use CodeMirror component for MathjaxHandle

* Refactor ResizeObserver code in MathjaxHandle

* Wrap setRange in CodeMirror in try/catch

* Add Mathjax Editor bottom margin

* Add custom Enter and Shift+Enter shortcuts for the MathjaxHandle

* Format

* Move placeCaretAfter to domlib

* Move focus back to field after editing Mathjax

* Put Cursor after Mathjax after accepting

* Add delete button for Mathjax

* Change border color of mathjax menu

* Refactor into MathjaxMenu

* Put caretKeyword in variable

* Use one ResizeObserver for all Mathjax images

* Add minmimum width for Mathjax editor

* is still smaller than minimal window width

* Add bazel directories to .prettierignore and format from root

* exclude ftl/usage (dae)

the json files that live there are output from our tooling, and
formatting them means an extra step each time we want to update them

also exclude .mypy_cache, which is output by scripts/mypy*

* minor ftl tweak: newline -> new line  (dae)
2021-11-23 10:27:32 +10:00
Henrik Giesel
a2aeaf456f Fix missing left margin in CongratsPage (#1498) 2021-11-19 11:02:54 +10:00
Henrik Giesel
cfe1895870 Reverse-engineer surrounding with execCommand (#1377)
* Add utility functions for saving and restoring the caret location

Implement surroundNoSplitting

Clarify surroundNoSplitting comments

Start implementing surroundSplitting and triggerIfSimpleInput

Fix after rebase

Implement findBefore / findAfter in lib/surround

* to merge adjacent nodes into the surrounding nodes

Use new prettier settings with lib/{location,surround}

Fix imports that I missed to rename

Add some tests for find-adjacent

Split find-within from find-adjacent

Normalize nodes after insertion in surroundNoSplitting

Do not deep clone surroundNode

-> no intention of supporting deep nodes, as normalization would be impossible

Add some tests concerning nested surrounding nested nodes

Select surroundedRange after surrounding

Fix ascendWhileSingleInline

A flawed first surround/trigger implementation

Move trigger out of lib/surround

Implement Input Manager as a way to handle bold on empty selection

Switch bold button away from execCommand

Pass in Matcher instead of selector to find-adjacent and surroundNoSplitting

* Also adds a failing test for no-splitting

Refactor find-adjacent

* add failing test when findBefore's nodes have different amounts of
  child nodes

Change type signature of find-adjacent methods to more single-concern

Add test for surrounding where adjacent block becomes three Text elements

Make nodes found within surrounded range extend the ranges endOffset

Add base parameter to surroundNoSplitting to stop ascending beyond container

Stop surrounding from bubbling beyond base in merge-match

Make all tests pass

Add some failing tests to point to future development

Add empty elements as constant

Implement a broken version of unsurround

Even split text if it creates zero-length texts

-> they are still valid, despite what Chromium says

Rename {start,end} to {start,end}Container

Add more unit tests with surround after a nested element

Set endOffset after split-off possibly zero length text nodes

Deal with empty elements when surrounding

Only include split off end text if zero length

Use range anchors instead off calcluating surroundedRange from offsets

* this approach allows for removal of base elements when unsurrounding

Comment out test which fail because of jsdom bugs

We'll be able to enable them again after Jest 28

Make the first unsurround tests pass

Add new failing test for unsurround text within tag

Fix unsurround

Test is deactivated until Jest 28

Rewrite input-manager and trigger callback after insertion

Avoid creating zero length text nodes by using insertBefore when appropriate

Implement matches vs keepMatches

Make shadow root and editable element available on component tree

Make WithState work with asynchronous updater functions

Add new Bold/Italic/UnderlineButton using our logic

Add failing test for unsurrounding

* Move surround/ to domlib

* Add jest dependency

* Make find-within return a sum type array rather than two arrays

* Use FoundMatch sum-type for find-above (and find-within)

* Fix issue where elements could be cleared twice

* if they are IN the range.endContainer

* Pass remaining test

* Add another failing test

* Fix empty text nodes being considered for surrounding

* Satisfy svelte check

* Make on more type correct

* Satisfy remaining tests

* Add missing copyright header
2021-11-18 19:18:39 +10:00
Henrik Giesel
88a637251b Introduce our own Container, Row, and Col components (#1495)
* Refactor out Placeholder from CardInfo.svelte

* Add breakpoint parameter for Container

- Use `Container` component inside `TitledContainer`

* Build Item into Row

- Use Row in DeckOptionsPage instead of just Item

* Reengineer Container/Row/Col CSS

* Inline Badges next to Labels when Lable spans multiple rows

* Adjust margins for mobile

* Implement Col component breakpoints

* Move card-info to use new Container and Row components

* Join StickyHeader and StickyFooter to StickyContainer

* Remove default middle vertical-alignment for Badges again

* Satisfy tests

* Restore inline gutters in change-notetype Mapper

* Add some comment to Col and Container

* Fix breaking behavior in DeckOptionsPage when multi-column

* Add back toolbar left padding to counter-act buttongroup right margins

* Make Label in SwitchRow take more of available space
2021-11-17 13:49:52 +10:00
Abdo
eb85653f0f Load missing i18n modules (#1494) 2021-11-17 07:28:48 +10:00
RumovZ
5c64aadb7a Garbage collect unused Fluent strings (#1482)
* Canonify import of i18n module

Should always be imported as `tr`, or `tr2` if there is a name collision
(Svelte).

* Add helper for garbage collecting ftl strings

Also add a serializer for ftl asts.

* Add helper for filter-mapping `DirEntry`s

* Fix `i18n_helpers/BUILD.bazel`

* run cargo-raze

* Refactor `garbage_collection.rs`

- Improve helper for file iterating
- Remove unused terms as well
- Fix issue with checking for nested messages by switching to a regex-
based approach (which runs before deleting)
- Some more refactorings and lint fixes

* Fix lints in `serialize.rs`

* Write json pretty and sorted

* Update `serialize.rs` and fix header

* Fix doc and remove `dbg!`

* Add binaries for ftl garbage collection

Also relax type constraints and strip debug tests.

* add rust_binary targets for i18n helpers (dae)

* add scripts to update desktop usage/garbage collect (dae)

Since we've already diverged from 2.1.49, we won't gain anything
from generating a stable json just yet. But once 2.1.50 is released,
we should run 'ftl/update-desktop-usage.sh stable'.

* add keys from AnkiMobile (dae)

* Mention caveats in `remove-unused.sh`
2021-11-12 18:19:01 +10:00
Damien Elmes
6220bdc33c fix card info layout & test code
Closes #1479

Related: #1470
2021-11-12 16:24:08 +10:00
Damien Elmes
0637f3190b another external workspace fix for sass 2021-11-12 15:02:17 +10:00
Henrik Giesel
dccd86c346 Save and restore location on ContentEditable (#1481)
* Add utility functions for saving and restoring the caret location

* Implement cross-browser.getSelection

* Save and restore location on ContentEditable

* Fix refocus by clicking on a field that had a non-collapsed selection
2021-11-09 12:53:39 +10:00
Matthias Metelka
1592fd0295 Editor Field Descriptions (#1476)
* Add description input to fields dialog

QLineEdit seems like the best option, as it saves space and motivates users to keep their descriptions concise.

* Add setDescriptions to note initialization script

Went for the extra function instead of including it in setFields to prevent potential add-on breakages.

* Add tooltip next to field name if description is set

* Refactor code according to suggestions

Set default tooltip placement to right instead of bottom

Use .get() for fld["description"]

Fix tab order in fields dialog

Swap out abbreviation "desc" for full length name to keep consistency

* Update Protobuf and Rust for description

Add description to notetypes.proto and schema11

Co-authored-by: RumovZ <RumovZ@users.noreply.github.com>

* Fix tooltips not updating with description

Remove redundant variable tooltipOptions

Update previousTooltip within reactive function

* Move LabelDescription out of LabelName

Co-authored-by: Henrik Giesel <hgiesel@users.noreply.github.com>

* Decrease icon size and fix alignment

Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>

* the new key needs to be cleared from fields, not the notetype itself

Co-authored-by: RumovZ <RumovZ@users.noreply.github.com>
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-06 09:42:48 +10:00
Henrik Giesel
b97dc23b96 Several editor fixes (#1478)
* Declare toolbar api via modifiable property

* Fix addon buttons

* Assign editing areas in a synchronous way

* Restore the Tab shortcut that moves the caret to end

- moveCaretToEnd is called twice now: The moveCaretToEnd calls in
  *TextInput causes the caret to be moved to the end when switching back
  from the window and back.
- To fix this, I will need the code for saving and restoring locations
  from #1377

* Restore selections in the PlainTextInput

* Improve type safety of destroyable

- clearable-array was renamed to destroyable
2021-11-05 11:29:02 +10:00
Damien Elmes
4fa8bad822 speed up Svelte compile
Approx 27s -> 16s when rebuilding editor after making a change to
lib. Still slower than I'd like.
2021-11-04 15:18:28 +10:00
Damien Elmes
bb427c9d26 add a missing references line in ts/graphs 2021-11-04 14:56:50 +10:00
Henrik Giesel
d654a57a90 Set "no-non-null-assertion: off" by default (#1475) 2021-11-04 11:42:51 +10:00
Damien Elmes
5e8580e137 ensure revlog headers match alignment of columns
+ right-align interval; it looks bad centered
2021-11-02 16:32:09 +10:00
Damien Elmes
600cbe5ded use absolute package paths in eslint.bzl 2021-11-02 13:49:19 +10:00
Damien Elmes
cc325d74b8 add lint checks for unsupported browser API calls 2021-11-02 13:44:41 +10:00
Damien Elmes
37df65d0c8 avoid Object.fromEntries() and some instances of globalThis
Not supported on early iOS 12. This can be reverted after iOS 12
support is dropped, which should be soon.
2021-11-02 12:54:06 +10:00
Damien Elmes
dd4c4eb07c include subfolders in eslint/prettier checks 2021-11-02 12:50:27 +10:00
Damien Elmes
5bad3d067c revert congrats h3 style change from #1470
Presumably bootstrap is overriding the styling of headers; this is a
quick fix to make the header be bold again, like the graphs screen.
2021-11-01 12:55:31 +10:00
Damien Elmes
032c7e49c3 allow passing npm repo name in compile_svelte() 2021-10-31 18:10:11 +10:00
Damien Elmes
a3a9523f6f use absolute path for sql_format 2021-10-31 11:13:38 +10:00
Henrik Giesel
d74c38abe5 Several CSS fixes - Editor Cleanup (#1470)
* Refactor editor css, fix editor button highlight

- Avoid using webview.css
- Move more buttons css into button_mixins

* Fix DropdownItem appearance

* Fix the visuals of tags

* Make dropdown font slightly smaller

* Give SelectOption a background color

* Move some css from deck-options-base to CardStateCustomizer

* Avoid using core.scss for CardStats

* Avoid using sass/core in congrats package

* Inline core.scss into webview.scss

* Include fusion-vars for base.scss

* need to keep core.scss around for now (dae)
2021-10-31 08:29:22 +10:00
Matthias Metelka
f85e2e8cef Highlight field badges when toggled to non-default state (#1466) 2021-10-31 07:48:37 +10:00
Henrik Giesel
915b638dcc Fix DeckOptions toolbar having wrong margins and no flex-grow (#1464)
ButtonToolbar.svelte now has to assume that the button elements
are two levels below it. This can be simplified once we can use
flex-gap.
2021-10-28 19:37:52 +10:00
Abdo
9e97ac1023 Strip isolation chars from deck options warnings to fix RTL display (#1457)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2021-10-26 20:11:25 +10:00
Damien Elmes
eee17476e3 fix deprecation warning in latest svelte-preprocess 2021-10-26 08:43:02 +10:00
Damien Elmes
fb3e6db1c7 update js deps 2021-10-26 08:30:13 +10:00
Damien Elmes
e28f03c65a //ts:format now runs on current working directory, instead of entire repo 2021-10-23 15:48:33 +10:00
Damien Elmes
1f736cea99 minor tweak to new-platforms.md, and run prettier on docs 2021-10-23 15:40:45 +10:00
Henrik Giesel
90b4d97e66 Fix RTL text display being off + Update PlainTextInput RTL on save (#1448) 2021-10-23 11:06:15 +10:00
RumovZ
3454c9ba30 Card info cleanup (#1446)
* Cast proto interface to type ...

... instead of using non-null assertions in Revlog.svelte.

* Remove OptionalInt32 and OptionalUInt32
2021-10-23 11:00:43 +10:00
Damien Elmes
5d72f008f9 vendor stringcase
It's a tiny library that has not been updated in years, and it was
leading to a warning on startup:

 DeprecationWarning: invalid escape sequence \W
  return re.sub("\W+", "", string)
2021-10-22 08:56:44 +10:00
Henrik Giesel
44f0cba3fa Fix Preview button not showing and cloze button not hiding (#1437) 2021-10-20 07:09:12 +10:00
Henrik Giesel
1d77c10b3d Use trailingComma: all setting in .prettierrc (#1435) 2021-10-19 09:06:00 +10:00
Henrik Giesel
6509b18a0d Svelte Editor hotfixes (#1436)
* Fix white on white text in light mode

* Reflect rename to FieldsEditor in class name

* Fix adjusting fields ending in an endless loop
2021-10-19 08:38:06 +10:00
Henrik Giesel
96b8f2c32d Translate Editor entirely to Svelte (#1403)
* Translate editor to Svelte

Make editor fields grid rather than flexbox

Refactor ButtonToolbar margins

Remove remaining svelte.d.ts symlinks

Implement saveNow

Fix text surrounding

Remove HTML editor button

Clean up some empty files

Add visual for new field state badges

* Adds new IconConstrain.svelte to generalize the icon handling for
IconButton and Badge

Implement sticky functionality again

Enable Editable and Codable field state badges

Add shortcuts to FieldState badges

Add Shift+F9 shortcut back

Add inline padding back to editor fields, tag editor and toolbar

Make Editable and Codable only "visually hidden"

This way they are still updated in the background
Otherwise reshowing them will always start them up empty

Make empty editing area focusable

Start with moving fieldsKey and currentFieldKey to context.ts

Fix Codable being wrong size when opening for first time

Add back drag'n'drop

Make ButtonItem display: contents again

* This will break the gap between ButtonGroup items, however once we
  have a newer Chromium version we should use CSS gap property anyway

Fix most of typing issues

Use --label-color background color LabelContainer

Add back red color for dupes

Generalize the editor toolbar in the multiroot editor to widgets

Implement Notification.svelte for showing cloze hints

Add colorful icon to notification

Hook up Editable to EditingArea

Move EditingArea into EditorField

Include editorField in editor/context

Fix rebasing issues

Uniformly use SvelteComponentTyped

Take LabelContainer out of EditingArea

Use mirror-dom and node-store to export editable content

Fix editable update mechanism

Prepare passing the editing inputs as slots

Pass in editing inputs as slots

Use codable options again in codemirror

Delete editor/lib.ts

Remove CodableAdapter, Use more generic CodeMirror component

Fix clicking LabelContainer to focus

Use prettier

Rename Editable to ContentEditable

Fix writing Mathjax from Codable to Editable

Correctly adjust output HTML from editable

Refactor EditableStyles out of EditableContainer

Pass Image and Mathjax Handle via slots to Editable

Make Editable add its editingInputApi

Make Editable hideable

Fix font size not being set correctly

Refactor both fieldFocused and focusInCodable to focusInEditable

Fix focusIfField

Bring back $activeInput

Fix ClozeButton

Remove signifyCustomInput

Refactor MathjaxHandle

Refactor out some logic into store-subscribe

Fix Mathjax editor

Use focusTrap instead of focusing div

Delegate focus back to editingInput when refocusing focusTrap

Elegantly move focus between editing inputs when closing/opening

Make Codable tabbable

Automatically move caret to end on editable and codable

+ remove from editingInput api

Fix ButtonDropdown having two rows and missing button margins

Make svelte_check and eslint pass

Satisfy editor svelte_check

Save field updates to db again

Await editable styles before mounting content editable

Remove unused import from OldEditorAdapter

Add copyright header to OldEditorAdapter

Update button active state from contenteditable

* Use activateStickyShortcuts after waiting for noteEditorPromise

* Set fields via stores, make tags correctly set

* Add explaining comment to setFields

* Fix ClozeButton

* Send focus and blur events again

* Fix Codable not correctly updating on blur with invalid HTML

* Remove old code for special Enter behavior in tags

* Do not use logical properties for ButtonToolbar margins

* Remove getCurrentField

Instead use noteEditor->currentField or noteEditor->activeInput

* Remove Extensible type

* Use context-property for NoteEditor, EditorField and EditingArea

* Rename parameter in mirror-dom.allowResubscription

* Fix cutOrCopy

* Refactor context.ts into the individual components

* Move focusing of editingArea up to editorField

* Rename promiseResolve -> promiseWithResolver

* Rename Editable->RichTextInput and Codable->PlainTextInput

* Remove now unnecessary type assertion for `getNoteEditor` and `getEditingArea`

* Refocus field after adding, so subscription to editing area is refreshed
2021-10-18 22:01:15 +10:00
Damien Elmes
0af57b4170 add aliases to run vendored python and node from command line
You can then do './scripts/python -m venv /path/to/venv' to create
a virtual env based on the bundled Python, which can be handy if
you don't happen to have the appropriate version of Python installed
separately.
2021-10-18 19:50:41 +10:00
Damien Elmes
7405023b9b convert sql_format to ts_project; move into separate folder 2021-10-18 19:39:45 +10:00
RumovZ
45836b2ff8 Use null for missing stats 2021-10-18 09:36:31 +02:00
RumovZ
bde763dcad sentCardId -> requestedCardId 2021-10-18 09:12:10 +02:00
RumovZ
ff9dd841ca Use null for unset cardId 2021-10-18 09:11:00 +02:00
RumovZ
8fb055d72e Default to includeRevlog = true 2021-10-18 09:04:49 +02:00
RumovZ
b5368a0e23 Center placeholder 2021-10-18 09:01:25 +02:00
RumovZ
424a50dcdc Improve clarity in card info code a tiny little bit 2021-10-18 09:01:25 +02:00
RumovZ
ae4677c1c2 Move update logic into CardInfo.svelte
Also use a simpler and faster way to avoid race conditions.
2021-10-18 09:01:24 +02:00
RumovZ
847bf3fe12 Move update logic into CardInfo.svelte 2021-10-18 09:01:24 +02:00
RumovZ
083d2db98b Make CardStats a separate component 2021-10-18 09:01:23 +02:00
RumovZ
80ae938fc8 Implement reactively updating Card Info 2021-10-18 09:01:22 +02:00
Damien Elmes
659a175a13 drop ts_library() requirement in ts/svelte 2021-10-18 13:00:55 +10:00
Damien Elmes
5be9ae5229 pass ts deps into most Svelte packages; remove redundant deps
Henrik, I've left editable/editor alone to avoid causing a conflict;
please add them in your PR instead when you get a chance.
2021-10-18 12:44:31 +10:00
Damien Elmes
a78852d636 Svelte build improvements
1. All Svelte files in a package are compiled in one step now, which
ensures that properties that use types from a different Svelte file in the
same package are typed correctly. The single-file svelte() has been removed,
and compile_svelte() may be renamed to svelte() in the future.

2. The .ts files in the same package are included as part of the Svelte
compilation, so that types imported imported from .ts files in the
same package work.

3. Dependencies passed into the rule are now loaded into the TypeScript
compiler, so that properties referencing types from different packages
work. We'll need to update our compile_svelte() lines to list the
dependencies. For example, before this change:

% cat bazel-bin/ts/congrats/CongratsPage.svelte.d.ts
import { SvelteComponentTyped } from "svelte";
declare const __propDef: {
    props: {
        info: any;
    };
...

After adding //ts/lib to the deps of compile_svelte() in ts/congrats:

% cat bazel-bin/ts/congrats/CongratsPage.svelte.d.ts
import { SvelteComponentTyped } from "svelte";
import type { Scheduler } from "../lib/proto";
declare const __propDef: {
    props: {
        info: Scheduler.CongratsInfoResponse;
    };
...
2021-10-18 12:44:29 +10:00
Damien Elmes
276d8cc5a5 pass sole arg to cardStats as a dictionary
Easier to extend in the future, or (de)serialize in a strongly-typed
language.
2021-10-14 19:28:51 +10:00
Damien Elmes
dde0ef372f layout tweaks to card info
- negative margins result in truncated text when the window size
is reduced, so avoid them
- having a 100% table inside a flexbox is not responsive - the table
does not adjust its size as the width is increased or decreased
- in order to look decent on narrow screens (eg phones), we allow
margin collapsing
- in order to look decent on wide screens, we limit the maximum
width to something that is readable
- hide some columns in portrait mode on narrow screens

I tried preserving the centering with margin-left/right: auto, but
could not get it looking right, so have had to move things back to
left alignment.
2021-10-14 19:28:33 +10:00
Damien Elmes
084384c2b0 support #test in card-info.html
allows us to use scripts/ts-run and ts-watch to test the page
in Chrome by surfing to http://127.0.0.1:40000/_anki/pages/card-info.html#testXXX
2021-10-14 19:23:33 +10:00
RumovZ
ea9fc3730e Switch CardInfoDialog to ts page (#1414)
* Only collect card stats on the backend ...

... instead of rendering an HTML string using askama.

* Add ts page Card Info

* Update test for new `col.card_stats()`

* Remove obsolete CardStats code

* Use new ts page in `CardInfoDialog`

* Align start and end instead of left and right

Curiously, `text-align: start` does not work for `th` tags if assigned
via classes.

* Adopt ts refactorings after rebase

#1405 and #1409

* Clean up `ts/card-info/BUILD.bazel`

* Port card info logic from Rust to TS

* Move repeated field to the top

https://github.com/ankitects/anki/pull/1414#discussion_r725402730

* Convert pseudo classes to interfaces

* CardInfoPage -> CardInfo

* Make revlog in card info optional

* Add legacy support for old card stats

* Check for undefined instead of falsy

* Make Revlog separate component

* drop askama dependency (dae)

* Fix nightmode for legacy card stats
2021-10-14 19:22:47 +10:00
Damien Elmes
3a795aae22 declare bootstrap prereq in Svelte compile
Mistakenly stripped this out when removing the typescript dependencies
2021-10-13 11:48:22 +10:00
Henrik Giesel
ac92155a8e Put sass into repo directory (#1409)
Fix Sass build
2021-10-09 10:25:03 +10:00
Henrik Giesel
2680d1bad8 Fix prettier after moving node_modules to repo dir (#1413) 2021-10-09 10:13:14 +10:00
Henrik Giesel
f0b61782be Refactor i18n (#1405)
Merging note: the typing changes were fixed in a separate PR.

* Put rootDirs into subprojects

- typings do not work for any ts or svelte files
- if we set the 'rootDirs' in ts/tsconfig.json to '../bazel-bin/ts' and then inherit
  them from e.g. editor, the root will be changed to '../../bazel-bin/ts',
  however editor needs look in '../../bazel-bin/ts/editor' instead.

* Rename i18n and i18n_helpers to i18n-generated and i18n

- This way, we can restrict the awkwardness of importing files outside
  the ts directory within lib

* Fix missing typing of i18n and backend_proto by adding back symlinks

* Split up i18n-generated into i18n-{translate,modules}

* Change i18n from singleton to functions

* Revert "Put rootDirs into subprojects"

This partially reverts commit e1d4292ce3.

It seems like this might not be necessary after all.
However some other change made on this branch seems to have fixed
the .svelte.d.ts imports

* Introduce i18n-bundles to remove circular import

There was a circular import i18n.ts <-> i18n-translate.ts

* Create own directory for i18n

* Move lib/i18n/translate to lib/translate

* This restores tree shaking

* Update tsconfig libs and module

* es2018-2020 have wide support on all modern browsers including

* Switch bundles and langs inside i18n to variables again

* Add missing copyright header

* Rename translate.ts to ftl.ts

* Remove the symlinks again

I added them to fix to have completion for tr, however this would have
also have meant to abandon the tree shaking.
As we want to have tree shaking, it's also not necessary to have the
symlinks anymore

* Revert "Update tsconfig libs and module"

This reverts commit 0a96776a47.

* move withCollapsedWhitespace back to i18n/utils

* Add back /ts as in rootDirs
2021-10-07 23:31:49 +10:00
Damien Elmes
13ffa43d7e svelte needs its shims to generate prop typing
I erroneously removed them near the end of the ts_project work, and
didn't realise the properties had broken.
2021-10-07 21:33:21 +10:00
Damien Elmes
7cc3b1816c fix invalid arg to ButtonGroup revealed by typing fix 2021-10-07 21:33:15 +10:00
Damien Elmes
f209a72b7c move node_modules into root folder [action required]
Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
https://github.com/ankitects/anki/pull/1405#issuecomment-936213861

Also fixes the sass errors shown when running scripts/svelte-check
2021-10-07 11:42:27 +10:00
Damien Elmes
af88b480f9 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
a5c7134d43 yarn upgrade --latest
bootstrap still held back
2021-10-01 12:52:53 +10:00
Damien Elmes
5d7eb8c425 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
7ce0b944bd 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
899d0556e8 handle changed aria-expanded typing 2021-09-29 12:20:27 +10:00
Damien Elmes
6db52323dd 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
9b994ac537 silence execCommand deprecation warnings for now 2021-09-29 11:36:37 +10:00
Damien Elmes
5d0736ab96 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
8f7e7498da update to TypeScript 4.4.x 2021-09-23 09:53:37 +10:00
Damien Elmes
81104f47f4 fixes for TypeScript 4.4.x
closes #1386
2021-09-23 09:52:21 +10:00
Damien Elmes
df26c61164 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
66608b06b0 Allow for explicit any 2021-09-17 21:30:32 +02:00
Henrik Giesel
16b6d95593 Make HandleSelection perfectly size when first activating 2021-09-17 21:23:04 +02:00
Henrik Giesel
1e2fa82446 Fix missizing of HandleSelection when first moving from empty to Mathjax 2021-09-17 20:54:37 +02:00
Henrik Giesel
82d93f3eae Ugly fix: do not execute moveCursorPastPostfix when front includes "anki-mathjax" 2021-09-17 20:12:11 +02:00
Henrik Giesel
222da3912a Add ChangeTimer.prototype.fireImmediately
so Mathjax is saved when exiting editor prematurely
2021-09-16 14:47:05 +02:00
Henrik Giesel
159e932f79 Wrap Mathjax compilation into try/catch 2021-09-16 14:31:20 +02:00
Henrik Giesel
4b0e35a357 Rename StickyBar and StickyBottom to StickyHeader and StickyFooter 2021-09-15 23:15:55 +02:00
Henrik Giesel
9f500cf78a Remove now unused import in TagEditor 2021-09-15 22:59:47 +02:00
Henrik Giesel
d6702c1c68 Fix suggestions not showing when typing space in a TagInput 2021-09-15 22:54:53 +02:00
Henrik Giesel
84eda7c547 Make the ImageHandle and MathjaxHandle dropdowns perfectly touch the HandleSelection 2021-09-15 22:26:32 +02:00
Henrik Giesel
f4aa6bf90b Stop propagation for paste in MathjaxHandle editor 2021-09-15 22:14:38 +02:00
Henrik Giesel
dbaba6233a Prevent hiding handles by clicking on handles 2021-09-15 17:56:56 +02:00
Henrik Giesel
d4c535183b Remove style attribute after remove float property if not styling left 2021-09-15 17:36:48 +02:00
Henrik Giesel
e10a5f0a38 Always correctly update MathjaxHandle position 2021-09-15 17:05:43 +02:00
Henrik Giesel
b7d8ae8f22 Correctly pass down dropdownObject... 2021-09-15 16:16:42 +02:00
Henrik Giesel
9d07639829 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
ca4430d922 Make StickyBottom actually stick and make editor fullsize + flexbox 2021-09-15 15:21:37 +02:00
Henrik Giesel
50cd722dc8 Import saveField from editor/saving.ts 2021-09-15 14:09:25 +02:00
Henrik Giesel
0fc5c87c1a Remove duplicate outline:none 2021-09-15 13:46:07 +02:00
Henrik Giesel
05cf123959 Apply specific CSS to Mathjax CodeMirror 2021-09-15 13:46:04 +02:00
Henrik Giesel
212b2ce8ba Satisfy eslint 2021-09-15 13:45:20 +02:00
Henrik Giesel
745c67fee5 Use editorfield instead of editor-field 2021-09-15 13:45:20 +02:00
Henrik Giesel
04d9ab1f56 Vertically center inline Mathjax 2021-09-15 13:45:20 +02:00
Henrik Giesel
75ee705c4e Generalize accesing anki-mathjax from image in MathjaxHandle 2021-09-15 13:45:20 +02:00
Henrik Giesel
f2dbe2415e Add copyright header to saving.ts 2021-09-15 13:45:20 +02:00
Henrik Giesel
722831ea8d Satisfy eslint 2021-09-15 13:45:19 +02:00
Henrik Giesel
975e798d70 Define CodeMirror in external codeMirror.ts 2021-09-15 13:45:19 +02:00
Henrik Giesel
5b03f51748 Correctly import CodeMirror 2021-09-15 13:45:19 +02:00
Henrik Giesel
9f201b7a7a Include codemirror libs for svelte 2021-09-15 13:45:19 +02:00
Henrik Giesel
65be772799 Satisfy eslint 2021-09-15 13:45:19 +02:00
Henrik Giesel
48912b016e Remove empty constructor 2021-09-15 13:45:19 +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
d6e2b794ec Change Wrap commands / shortcuts to use anki-mathjax 2021-09-15 13:42:36 +02:00
Henrik Giesel
eb2c81c79f Refactor editable/mathjax.ts 2021-09-15 13:33:25 +02:00
Henrik Giesel
9d671581ac Set fixed fontSizef or mathjax in editor for now 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
7b509f8313 Wrap Mathjax buttons into toolbar 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
1f477916e6 Move setting inCodable to false into codable 2021-09-15 13:33:23 +02:00
Henrik Giesel
64b971c464 Display Mathjax error as title (tooltip) 2021-09-15 13:33:23 +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
428b292768 Disallow draggin of mathjax + only ever have one handle active 2021-09-15 13:33:21 +02:00
Henrik Giesel
875c6fe85f Fix return behavior on Mathjax decorated element 2021-09-15 13:33:21 +02:00
Henrik Giesel
b7be5ed3b5 Watch for childList instead of subtree 2021-09-15 13:33:21 +02:00
Henrik Giesel
dfee30dbe5 Display Mathjax editor and buttons at the same time 2021-09-15 13:33:20 +02:00
Henrik Giesel
8cadb90d29 Generalize ChangeTimer and use it in Mathjax editor 2021-09-15 13:33:20 +02:00
Henrik Giesel
631b985d12 Add ResizeObserver for MathjaxHandle 2021-09-15 13:33:20 +02:00
Henrik Giesel
f342edc43c Update editor when editing Mathjax 2021-09-15 13:33:19 +02:00
Henrik Giesel
5646bd34b4 Wait for stylesheets to load before setting field content 2021-09-15 13:33:19 +02:00
Henrik Giesel
269f09d739 Move elements inserted into decorated component no matter the position 2021-09-15 13:33:19 +02:00
Henrik Giesel
35098d0f40 Fix some cases where Mathjax whitespace formatting is destroyed 2021-09-15 13:33:19 +02:00
Henrik Giesel
0a003c7856 Use CodeMirror for Mathjax Editor 2021-09-15 13:33:18 +02:00
Henrik Giesel
0bb3696aa1 Autoupdate mathjax image
* propably should use changeTimer here
2021-09-15 13:33:18 +02:00
Henrik Giesel
c2fa9f3218 Fix focus issues with Mathjax editor 2021-09-15 13:33:18 +02:00
Henrik Giesel
e48ab77de2 First implementation of MathjaxHandleEditor
+ use manual focus highlighting on editing-area
2021-09-15 13:33:17 +02:00
Henrik Giesel
02d76240dd Make Mathjax menu also a floating dropdown menu like ImageHandle 2021-09-15 13:33:17 +02:00
Henrik Giesel
5589e2f7e1 Fix MathJax overlay after rebase 2021-09-15 13:33:17 +02:00
Henrik Giesel
90b0000f7b Add InlineBlock buttons to mathjax components 2021-09-15 13:33:12 +02:00
Henrik Giesel
70e4fd5a3b Add HandleControl to MathjaxHandle 2021-09-15 13:32:33 +02:00
Henrik Giesel
5bef89312e Display Mathjax handle when clicking mathjax 2021-09-15 13:32:33 +02:00
Henrik Giesel
7981cefb0c Rename showImageHandle to showHandles 2021-09-15 13:32:33 +02:00
Henrik Giesel
b092bd9f6d Formalize "Decorated components API" 2021-09-15 13:32:32 +02:00
Henrik Giesel
022143b38b Implement moveNodesInsertedBeforeEndToAfterEnd
This will prevent the user typing into the decorated elements
by accident because they place cursor behind it
2021-09-15 13:32:32 +02:00
Henrik Giesel
2787d7e7fd Unify anki-mathjax-* to just anki-mathjax 2021-09-15 13:32:32 +02:00
Henrik Giesel
d0e3bff267 Add MathjaxHandle 2021-09-15 13:32:32 +02:00
Henrik Giesel
3529e50f46 Implement latex highlighting for Latex in codable 2021-09-15 13:32:32 +02:00
Henrik Giesel
b2c9e672d4 Use margin:auto instead of text-align:center for mathjax-block 2021-09-15 13:32:31 +02:00
Henrik Giesel
7162a9b961 Do not start ImageHandle for images with [data-anki] 2021-09-15 13:32:31 +02:00
Henrik Giesel
7255312ec5 Nicely portray mathjax with right color + alignment in Editor 2021-09-15 13:32:31 +02:00
Henrik Giesel
1d05ada05b Enable edit mode for mathjax blocks 2021-09-15 13:32:31 +02:00
Henrik Giesel
9ca8e07bbe Correctly include editable css 2021-09-15 13:32:31 +02:00
Henrik Giesel
47653e9672 Survive to Codable and back 2021-09-15 13:32:31 +02:00
Henrik Giesel
24b852b99a Transform to mathjax components for fieldHTML 2021-09-15 13:32:31 +02:00
Henrik Giesel
49d2dd6660 Implement MathjaxBlock 2021-09-15 13:32:30 +02:00
Henrik Giesel
5811e59f27 Introduce editable module 2021-09-15 13:32:30 +02:00
Henrik Giesel
4f6468a925 Prevent tooltip expanding body tag in editor 2021-09-15 02:24:09 +02:00
Henrik Giesel
6c8767cd68 Do not stop showing suggestions when entering double colon for separator 2021-09-15 02:02:19 +02:00
Damien Elmes
b0350bafa7 bikeshedding: amount -> match_limit
+ convert from u32 in backend method
2021-09-12 11:57:49 +10:00
Henrik Giesel
9d0c3e0855 Cap tag suggestions at 500 2021-09-10 01:13:50 +02:00
Henrik Giesel
63398df036 Fix crosshair not showing on main text of Tag when in select mode 2021-09-09 22:31:16 +02:00
Henrik Giesel
27c6003038 Introduce TagEditMode as a wrapper around TagWithTooltip 2021-09-09 21:47:07 +02:00
Henrik Giesel
e8f4872391 Only hide DeleteBadge when hovering on tag 2021-09-09 20:16:52 +02:00
Henrik Giesel
80898d1954 Align suggestions with start of tag 2021-09-09 19:03:06 +02:00
Henrik Giesel
b46dcb5c72 Only show tag tooltip on hover, not focus 2021-09-09 18:36:29 +02:00
Henrik Giesel
f7a69e5e9a Scroll suggestion tag into view 2021-09-09 18:32:58 +02:00
Henrik Giesel
7150e1f149 Do not use overflow-x on ButtonToolbar
* Fixes deck-options dropdown not showing.
  It seems like it's no longer necessary
2021-09-09 17:50:02 +02:00
Henrik Giesel
51718134ea Fix Tag SPACER 2021-09-09 17:28:00 +02:00
Henrik Giesel
a1ca2cf4b9 Bubble up some functionality from Tag to TagWithTooltip and TagDeleteBadge 2021-09-09 17:18:47 +02:00
Henrik Giesel
71d4b4d9f7 Remove unused import 2021-09-09 15:38:12 +02:00
Henrik Giesel
8bbc001273 Fix bug where sometimes Autocomplete menu would not show even though suggestions exist 2021-09-09 15:38:11 +02:00
Henrik Giesel
bbba7307b3 Use noSuggestions 2021-09-09 15:38:11 +02:00
Henrik Giesel
500619d5cc Update Autocomplete position when suggestion selection makes it move to the next row 2021-09-09 15:38:10 +02:00
Henrik Giesel
9755b25fb1 Set disabled class on TagInput from WithAutocomplete 2021-09-09 15:38:10 +02:00
Henrik Giesel
e805c45403 Explicitly not support dropleft/dropright
We'll deal with it when we have a use case
2021-09-09 15:38:09 +02:00
Henrik Giesel
f34112ee28 Correctly place dropdown and only update if there's activeInput 2021-09-09 15:38:09 +02:00
Henrik Giesel
3fed669c45 Take most recent input as basis for suggestions 2021-09-09 15:38:09 +02:00
Damien Elmes
c83843812e add basic tag completion to backend
Matches should arrive in alphabetical order. Currently results are not
capped (JS should be able to handle ~1k tags without too much hassle),
and no reordering based on match location is done. Matches are substring
based, and multiple can be provided, eg "foo::bar" will match
"foof::baz::abbar".

This is not hooked up properly on the frontend at the moment -
updateSuggestions() seems to be missing the most recently typed character,
and is not updating the list of completions half the time.
2021-09-09 15:38:08 +02:00
Henrik Giesel
cfee5fb986 Decrease tag margins 2021-09-09 15:38:08 +02:00
Henrik Giesel
8b2e69b912 Add bottom padding to selected tag badge as well 2021-09-09 15:38:07 +02:00
Henrik Giesel
a7b01537f6 Use new style highlight for selected tags 2021-09-09 15:38:07 +02:00
Henrik Giesel
7aa599e72c Add slight padding around add tag icon 2021-09-09 15:38:07 +02:00
Henrik Giesel
cc430c5994 Add a zero-width tag to prevent resizing when adding tag 2021-09-09 15:38:06 +02:00
Henrik Giesel
047e466c98 Un-reverse TagEditor autocompletion navigation 2021-09-09 15:38:06 +02:00
Henrik Giesel
6f41c83587 Decrease padding of AutocompleteItem 2021-09-09 15:38:06 +02:00
Henrik Giesel
6af355f8d0 Adjust border radius of tags to fit new fields 2021-09-09 15:38:05 +02:00
Henrik Giesel
b70124a1e6 Update to use shortened SCSS paths for some components 2021-09-09 15:38:05 +02:00
Henrik Giesel
c15fcb8b7e Satisfy formatter 2021-09-09 15:38:04 +02:00
Henrik Giesel
deb572e637 Rename tagEditor tag-editor.ts 2021-09-09 15:38:04 +02:00
Henrik Giesel
3873c29022 Refer to ./ instead of components/ from within components 2021-09-09 15:38:04 +02:00
Henrik Giesel
e3fe65fc23 Fix ts/components:svelte_check 2021-09-09 15:38:03 +02:00
Henrik Giesel
5dc8224a1b Add scrollbar_lib to components 2021-09-09 15:38:03 +02:00
Henrik Giesel
22d63ec5fa Fix eslint 2021-09-09 15:38:02 +02:00
Henrik Giesel
9e12b25d21 Fix colon insertion behavior 2021-09-09 15:38:02 +02:00
Henrik Giesel
879cd116a6 Replace delim char with colons on copying tags 2021-09-09 15:38:02 +02:00
Henrik Giesel
0db1b9cc78 Fix TagSpacer 2021-09-09 15:38:01 +02:00
Henrik Giesel
93ba4a2cd8 Implement nowrap mode 2021-09-09 15:38:01 +02:00
Henrik Giesel
bf6e587161 Implement TagWithTooltip 2021-09-09 15:38:00 +02:00
Henrik Giesel
9e91307c5d Move WithTooltip to components 2021-09-09 15:38:00 +02:00
Henrik Giesel
cc9e3e2455 Use Unicode delimiter character 2021-09-09 15:38:00 +02:00
Henrik Giesel
58dc22ee7b Improve space behavior 2021-09-09 15:37:59 +02:00
Henrik Giesel
f5feed589e Improve enter behavior 2021-09-09 15:37:59 +02:00
Henrik Giesel
39a1f6199e Split when no autocomplete item is selected 2021-09-09 15:37:59 +02:00
Henrik Giesel
c0944ec3a1 Add tag shorting behavior 2021-09-09 15:37:58 +02:00
Henrik Giesel
a49fd5ab2a Space out Sticky Bottom with Spacer component 2021-09-09 15:37:58 +02:00
Henrik Giesel
494d1e206d Deselect on clicking delete icon 2021-09-09 15:37:58 +02:00
Henrik Giesel
98baca8809 Add small horizontal margin so selected highlight can show 2021-09-09 15:37:57 +02:00
Henrik Giesel
596e7e0e70 Special handling of Backspace/Delete etc. for displaying shortcuts 2021-09-09 15:37:57 +02:00
Henrik Giesel
9682e84452 Add select all shortcut
+ Remove addEventListener for Ctrl+C/V/A
  It seems like they're really not necessary
2021-09-09 15:37:57 +02:00
Henrik Giesel
09f00a92aa Position stickyBottom fixed 2021-09-09 15:37:56 +02:00
Henrik Giesel
37d30284fc Improve positioning of tag editor badges 2021-09-09 15:37:56 +02:00
Henrik Giesel
928866b5aa Fix after rebase 2021-09-09 15:37:56 +02:00
Henrik Giesel
c8bcca517b Improve paste behavior 2021-09-09 15:37:55 +02:00
Henrik Giesel
2fc5c73b74 Do not update/activate Autocomplete on Control+C,A,V 2021-09-09 15:37:55 +02:00
Henrik Giesel
5a41409f54 Do not open autocomplete on clicking input 2021-09-09 15:37:55 +02:00
Henrik Giesel
b91db34aec Allow clicking on suggestion items 2021-09-09 15:37:54 +02:00
Henrik Giesel
964e97a384 Pass activeName to Tag as well 2021-09-09 15:37:54 +02:00
Henrik Giesel
444afa5b00 Adjust position so tags do not even move a single pixel when going into editing 2021-09-09 15:37:54 +02:00
Henrik Giesel
6af2ab437e Adjust paddings a bit more 2021-09-09 15:37:54 +02:00
Henrik Giesel
5bb6df757e Center delete icon without padding/margin 2021-09-09 15:37:53 +02:00
Henrik Giesel
58c35f316d Fix autocomplete dropdown
+ find a different solution for making tags and tag inputs same size
2021-09-09 15:37:53 +02:00
Henrik Giesel
e3be5972b8 Switch WithAutocomplete to WithDropdown and fix SelectedTagBadge 2021-09-09 15:37:53 +02:00
Henrik Giesel
a576228c08 Add SelectedTagBadge to offer context items for selected tags 2021-09-09 15:37:53 +02:00
Henrik Giesel
408ff4f061 Implement selectRange 2021-09-09 15:37:52 +02:00
Henrik Giesel
b178b86afd Make automatic deselect when leaving tag editor 2021-09-09 15:37:52 +02:00
Henrik Giesel
2fc7602406 Make tags selectable 2021-09-09 15:37:52 +02:00
Henrik Giesel
984afb8812 Implement controlPressed and shiftPressed 2021-09-09 15:37:52 +02:00
Henrik Giesel
9f0bf7484b Create lib/keys.ts 2021-09-09 15:37:52 +02:00
Henrik Giesel
81274169cd First steps toward tag selection 2021-09-09 15:37:51 +02:00
Henrik Giesel
c8c86d376a Implement autocomplete hiding on empty activeInput + remove logging 2021-09-09 15:37:51 +02:00
Henrik Giesel
b2d9500816 Fix behavior when autocompletion shows 2021-09-09 15:37:51 +02:00
Henrik Giesel
033f39f52f Fix join behavior and exclude Backspace/Delete from printable character 2021-09-09 15:37:51 +02:00
Henrik Giesel
8d8dd4fca0 Disable toggle on clicking element (toggle) for WithAutocomplete 2021-09-09 15:37:51 +02:00
Henrik Giesel
84d060a5b8 Improve no reflow a little bit 2021-09-09 15:37:51 +02:00
Henrik Giesel
b4860fbc6b Fix autocomplete showing on arrow keys and height resize on no tags 2021-09-09 15:37:50 +02:00
Henrik Giesel
8a648a4bcf Implement accepting suggestions via Enter 2021-09-09 15:37:50 +02:00
Henrik Giesel
b6ffc4d071 Introduce AutocompleteItem
* needs too much custom styling / behavior to be done with DropdownItem
2021-09-09 15:37:50 +02:00
Henrik Giesel
d2d6623788 suggestions -> suggestionsPromise, so it works with external APIs 2021-09-09 15:37:50 +02:00
Henrik Giesel
d5eff3b75c Don't allow Enter/Tab/Arrows for Autocomplete, if not active
Don't show Autocomplete, if there are no items available
2021-09-09 15:37:49 +02:00
Henrik Giesel
c18c0dd5b9 Have WithAutocomplete export its API
allows it to be used in more contexts
2021-09-09 15:37:49 +02:00
Henrik Giesel
85a5f627be Rename TagAutocomplete to WithAutocomplete
It's general enough to be used in other cases too
2021-09-09 15:37:49 +02:00
Henrik Giesel
6bf478acdf Improve visuals of Tag component 2021-09-09 15:37:49 +02:00
Henrik Giesel
477796fb3d Save deletions via delete icon to db 2021-09-09 15:37:48 +02:00
Henrik Giesel
fc5dffbf86 Save tags back to Python 2021-09-09 15:37:47 +02:00
Henrik Giesel
51732b4470 Set tags from Python 2021-09-09 15:37:47 +02:00
Henrik Giesel
72b4487f39 Remove deleteActiveTag, fix appendEmptyTag 2021-09-09 15:37:47 +02:00
Henrik Giesel
a88af9954c Fix some deletion behavior 2021-09-09 15:37:47 +02:00
Henrik Giesel
151a64af7f Make Autocomplete dismount along with TagInput on blur 2021-09-09 15:37:47 +02:00
Henrik Giesel
263ee2364d Implement on:autocomplete 2021-09-09 15:37:46 +02:00
Henrik Giesel
978b2d6227 Don't highlight suggestion items
Other suggestions menus don't do it either
2021-09-09 15:37:46 +02:00
Henrik Giesel
3d013fd521 Fix tagmove 2021-09-09 15:37:46 +02:00
Henrik Giesel
5b473df41c Introduce activeName so we can pass it to TagAutocomplete 2021-09-09 15:37:45 +02:00
Henrik Giesel
253c6d702b Export choice as autocompletionChoice from TagAutocomplete 2021-09-09 15:37:45 +02:00
Henrik Giesel
3a7df7ca40 Make tagunique a more general tagaccept
* tagaccept includes what was previous done by on:blur
* on:blur in TagInput was in some cases not bubbled up to TagEditor for some reason
2021-09-09 15:37:45 +02:00
Henrik Giesel
b59c5bcc8d Use Autocomplete on TagInput again 2021-09-09 15:37:44 +02:00
Henrik Giesel
60faccebc0 Pass original to Autocomplete 2021-09-09 15:37:44 +02:00
Henrik Giesel
2a10d1a236 Fix TagBadge and TagSpacer + shortcut 2021-09-09 15:37:44 +02:00
Henrik Giesel
415c473d89 Export blink as a function, works more reliably 2021-09-09 15:37:43 +02:00
Henrik Giesel
b842a1d6f2 Fix behavior when simply entering a duplicate 2021-09-09 15:37:43 +02:00
Henrik Giesel
6a3b88cfb8 Implement tagsplit 2021-09-09 15:37:43 +02:00
Henrik Giesel
d706640acd Fix tagjoinnext 2021-09-09 15:37:43 +02:00
Henrik Giesel
a4ca20d852 Fix tagjoinprevious 2021-09-09 15:37:43 +02:00
Henrik Giesel
1766162241 Fix tagmove 2021-09-09 15:37:42 +02:00
Henrik Giesel
20971037ab Fix TagBadge and TagSpacer 2021-09-09 15:37:42 +02:00
Henrik Giesel
0a6dcfd55b Align tagenter tagdelete and tagunique 2021-09-09 15:37:42 +02:00
Henrik Giesel
da713badc0 Implement decideAfterBlur and activeAfterBlur 2021-09-09 15:37:42 +02:00
Henrik Giesel
02fc7cc16f Prefer focusing TagInput in onMount 2021-09-09 15:37:41 +02:00
Henrik Giesel
75783fff7c Completely decouple Tag from TagInput 2021-09-09 15:37:41 +02:00
Henrik Giesel
ea08e89d33 Add .input to Tag interface 2021-09-09 15:37:41 +02:00
Henrik Giesel
f6927bea41 Remove special treatment of last tag 2021-09-09 15:37:41 +02:00
Henrik Giesel
da3ea03694 Try to remove special handling of last tag / inputNew 2021-09-09 15:37:40 +02:00
Henrik Giesel
13f16790d6 Improve behavior when moving towards newInput 2021-09-09 15:37:40 +02:00
Henrik Giesel
f6ca173d0c tagmove should act like tagjoin on empty inputs 2021-09-09 15:37:40 +02:00
Henrik Giesel
5999b3459b Fix double delete on empty input 2021-09-09 15:37:40 +02:00
Henrik Giesel
7a7c862fa9 Implement blink on duplicate detected 2021-09-09 15:37:39 +02:00
Henrik Giesel
12a3d83d0a Add some visual for TagAutocomplete 2021-09-09 15:37:39 +02:00
Henrik Giesel
8d691c217a Minimize reflow upon clicking tag 2021-09-09 15:37:39 +02:00
Henrik Giesel
b91d20bd85 Implement tagmovenext fully 2021-09-09 15:37:39 +02:00
Henrik Giesel
8fd2f1a8c4 Almost implement tagmove
* tagmovenext will start on the last position rather than first
2021-09-09 15:37:38 +02:00
Henrik Giesel
8a6067958f Reimplement tagjoin with tick() 2021-09-09 15:37:38 +02:00
Henrik Giesel
766270a7bf Start implemention tagmove 2021-09-09 15:37:38 +02:00
Henrik Giesel
a8b002acee Set caret correctly after tagjoin 2021-09-09 15:37:38 +02:00
Henrik Giesel
e6bd66b894 Show Autocomplete on keydown, hide on blur 2021-09-09 15:37:38 +02:00
Henrik Giesel
2629afe6b0 Adjust padding of TagInput a little 2021-09-09 15:37:37 +02:00
Henrik Giesel
a0c44f55db Fix some WithDropdownMenu logic 2021-09-09 15:37:37 +02:00
Henrik Giesel
e368cf09a8 Factor out ButtonToolbar from TagAutocomplete 2021-09-09 15:37:37 +02:00
Henrik Giesel
0d394814e7 Decouple TagInput from TagAutocomplete completely 2021-09-09 15:37:37 +02:00
Henrik Giesel
7b6f49577a Add tabbable option to DropdownItem 2021-09-09 15:37:37 +02:00
Henrik Giesel
f52ad747cb Fix issue with text showing below StickyBottom 2021-09-09 15:37:37 +02:00
Henrik Giesel
68509995d5 Make tags stand less out in dark mode 2021-09-09 15:37:36 +02:00
Henrik Giesel
178062fc2d Make styling of DropdownMenu easier by introducing dropdown-content 2021-09-09 15:37:36 +02:00
Henrik Giesel
e287b396f9 Decouple Autocomplete from TagInput:
Allows to only have one autocompletion for all tags, rather than every
tag having its own
2021-09-09 15:37:36 +02:00
Henrik Giesel
59ef4259f5 Remove dead code from TagAutocomplete 2021-09-09 15:37:36 +02:00
Henrik Giesel
b778653851 Implement tagjoin events 2021-09-09 15:37:36 +02:00
Henrik Giesel
bbb4084f03 Delete tag when update reveals its a duplicate 2021-09-09 15:37:35 +02:00
Henrik Giesel
9706b1e15c Enable keyed blocks in TagEditor for tags 2021-09-09 15:37:35 +02:00
Henrik Giesel
0fcead4843 Rewrite paste behavior 2021-09-09 15:37:35 +02:00
Henrik Giesel
a4f52f82d8 Delete when updating tagname to empty text 2021-09-09 15:37:35 +02:00
Henrik Giesel
3869db8c86 Connect Bootstrap dropdown with trigger via classes/props 2021-09-09 15:37:34 +02:00
Henrik Giesel
6e563ddf49 Use our DropdownMenu component for TagAutocomplete 2021-09-09 15:37:34 +02:00
Henrik Giesel
3d594c1883 Allow correctly adding tags
+ Make taginput unfocusable via Tab => prefer Ctrl+Shift+T
2021-09-09 15:37:34 +02:00
Henrik Giesel
2a30eccfa4 Make caret cursor more discoverable 2021-09-09 15:37:34 +02:00
Henrik Giesel
eff5df2c69 Remove TagInputEdit and TagInputNew 2021-09-09 15:37:34 +02:00
Henrik Giesel
d89a6af45f Port Focus tags shortcut to webview 2021-09-09 15:37:34 +02:00
Henrik Giesel
f047441c18 Behave correctly upon Enter on TagInputEdit 2021-09-09 15:37:34 +02:00
Henrik Giesel
cecbafcec8 Create AddTagBadge component 2021-09-09 15:37:33 +02:00
Henrik Giesel
2b9e32fb08 Make Tag icon an add tag icon 2021-09-09 15:37:33 +02:00
Henrik Giesel
bcd6e037f2 Adjust offsets and sizes to make tag input smaller 2021-09-09 15:37:33 +02:00
Henrik Giesel
4aaba0875f Enable tag delete icon 2021-09-09 15:37:33 +02:00
Henrik Giesel
016d815ee1 Port most components from first tageditor PR 2021-09-09 15:37:33 +02:00
Henrik Giesel
7f6e7235f1 Display a tag-outline icon in the bottom left 2021-09-09 15:37:33 +02:00
Henrik Giesel
9919cf2b47 Add Tag DeleteIcon 2021-09-09 15:37:33 +02:00
Henrik Giesel
8b92ba7fa4 Add Tag.svelte 2021-09-09 15:37:33 +02:00
Henrik Giesel
37fdefaf40 Mount TagEditor 2021-09-09 15:37:33 +02:00
Damien Elmes
0c94600be6 Merge pull request #1357 from hgiesel/preventstickybubble
Prevent sticky bubble
2021-09-08 19:02:00 +10:00
Henrik Giesel
6b633fc275 However bubble up when clicking on label container itself 2021-09-07 15:02:59 +02:00
Henrik Giesel
828cf80f68 Put sticky tooltip on icon, not label container 2021-09-07 14:33:15 +02:00
Henrik Giesel
26e9fa1c01 Prevent sticky bubbling and saveField before toggling sticky 2021-09-07 14:33:05 +02:00
Damien Elmes
1aad956872 fix case of fields table 2021-09-07 10:22:22 +10:00
Damien Elmes
d96b017d52 remove recursive symlink
https://github.com/ankitects/anki/pull/1332#issuecomment-913572914
2021-09-06 21:26:30 +10:00
Henrik Giesel
90dc1a0b40 Fix Float buttons in rtl 2021-09-06 21:15:37 +10:00
Henrik Giesel
803bf1b9d4 Fix ButtonDropdown disappearing when mouseupping on HandleBackground 2021-09-06 21:15:37 +10:00
Henrik Giesel
912fb0d94d Fix Tab not moving caret to end 2021-09-06 21:15:37 +10:00
Henrik Giesel
57eb988068 Make clicking on labelcontainer move focus to field 2021-09-06 21:15:37 +10:00
Henrik Giesel
997e28384d Decrease margin of the pin icon on the right 2021-09-06 21:15:37 +10:00
Henrik Giesel
b7ca721a2c Have a uniform border-radius for buttons and fields 2021-09-06 21:15:37 +10:00
Henrik Giesel
212fd00405 Add a dashed border around pictures when image-editing 2021-09-06 21:15:37 +10:00
Henrik Giesel
63bc3f823b Make focus highlight artificial and based on :focus-within 2021-09-06 21:15:37 +10:00
Henrik Giesel
b40f7ef262 Remove comma 2021-09-06 21:15:37 +10:00
Henrik Giesel
214b674cad Prevent overflow of sizeDimensions or image handle buttons 2021-09-06 21:15:37 +10:00
Henrik Giesel
abf0eb1c16 Fix automatic positioning of ButtonDropdown after changing float property 2021-09-06 21:15:37 +10:00
Henrik Giesel
620f9cb765 Introduce WithImageConstrained 2021-09-06 21:15:37 +10:00
Henrik Giesel
732886ea7e Parameterize overlay handle offsets 2021-09-06 21:15:37 +10:00