This was implemented by me to prevent seemingly empty fields,
which however still contain some HTML (e.g. <div></div>) and
thus will trigger in the templates.
However it only worked in very limited cases, maybe we could
solve this better by indicating whether a field has content somehow.
* Instead of transforming to {\lt}, transform to <
- In Mathjax editor
- This way you can also use Mathjax convenience shortcuts like <=> in
chemistry mode: \ce{<=>}
* Remove unused translateEntitiesToMathjax() (dae)
https://github.com/ankitects/anki/pull/1818#discussion_r857238310
In the absence of strong arguments either way, and given the fact that
strong/em has broken a few (perhaps rare) use-cases, reverting seems
prudent. But happy to revisit this again in the future if someone has
a convincing argument for why we should be doing it differently.
Closes#1807
* Fix shift removing bold formatting
* Remove input handler on selection change
We listened to "non-input events" mostly to catch events that
change the selection (like Ctrl-a, or arrow keys) anyway
* Revert "Revert "Speed up editor by lazily loading CodeMirror (#1766)""
This reverts commit b0a2884f19.
* Pass in options via action update + Make access to editor optional
* First attempt at adding a directory for icons under //ts
* Fix image import
* Fix import order
* Add cloze button group
* Fix issue with toolbar.toolbar dynamically slottable
* Change tooltip for repeating cloze deletion
* Fix repeat cloze button not working on macOS (dae)
* Use async function in PlainTextInput
* Clean up PlainTextInput
* Refactor logic from {Rich,Plain}TextInput into own files
* Remove prohibited tags on content.subscribe which also parses the html
Issue report:
https://forums.ankiweb.net/t/anki-2-1-50-beta-6-release-candidate/18181/71
Localization was added in #1566. It works fine in the Qt5 build, but
the Qt6 build appears broken. This appears to be a change in Chromium,
and the latest Chrome has the same issue. Whether it's a legitimate bug
on their end, a deliberate change in behaviour, or we're doing something
wrong, I do not know.
* Extend maximum answer time...
Previously the time allowed to answer a question was capped at 10 minutes.
While this makes sense for fact recall, it limits the utility of Anki when
used for solving problems that can take more time to work through. This
extends the maximum answer time to 2 hours, which seems to be a reasonable
upper limit for solving a math or algorithm question.
* Add warning when max answer time exceeds 10 minutes
* Move warning below input field
* Start using WithFloating for SelectedTagBadge
* Adjust arrow on WithFloating for all directions
* Move TagOptionsBadge to its own sub directory
* Show autocomplete menu via WithFloating
* Have WithFloating return asReference instead of initializing its own reference element
* Add html: overflow: hidden for editor
* Replace ButtonToolbar with generic div
* Move scroll logic into autocomplete item + restrict Popover width to 95vw
* Fix autocomplete menu after pressing enter after selecting
- should not trigger an autocomplete choose
* Overlap TagInput perfectly with Tag
* Satisfy formatter
* Fix autocompletion item scrolling too much
* Remove unused Tag.svelte focusable prop
* Remove console.log
* Fix floating arrow is a diamond in dark mode
* Set autocompletion menu to 80vw
* Load fields_web from fields.py if appropriate flag is set
* Add FieldsPage as entry for new fields view
* Pass mypy
* Fix pylint
* Fix fields_web in Qt5 (dae)
May not be related to the CI error, but required for compatibility
with Qt5.
* Implement a first version of WithFloating and Portal
* Add outside slot for Portal
* Execute computePosition from WithFloating
* Set up a first example of new WithFloating with the Latex menu
* Use autoUpdate in WithFloating
* Create sveltelib/position
* Add event-store
* Use event-store in close-on-click
* Implement subscribeToUpdates
* Introduce sass/elevation
* Split close-on-click to closing-click and subscribe-trigger
* Have closing-* stores return a symbol
- This way they act more of an EventEmitter than a store
* Allow passing show store
* Remove styling on float on updatePosition removal
* Implement a nice border for dropdowns
* Apply different border and box-shadow to Popover in dark/light theme
* Fix Ctrl+Shift+T not working
* Satisfy formatters and tests
* Add copyright header
* move copyright header to top (dae)
* Use async functions in CodeMirror.svelte
* Fix using async functions by modifying svelte-preprocess output
* Revert "Fix using async functions by modifying svelte-preprocess output"
This reverts commit 94c9cadaaa3ca2084780833e9efc7807f2f1d1a9.
Trying a different fix.
* Change TypeScript target to ES2019
Protobuf 3.15 introduced support for marking scalar fields like
uint32 as optional, and all of our tooling appears to support it
now. This allows us to use simple optional/null checks in our Rust/
TypeScript code, without having to resort to an inner message.
I had to apply a minor patch to protobufjs to get this working with
the json-module output; this has also been submitted upstream:
https://github.com/protobufjs/protobuf.js/pull/1693
I've modified CardStatsResponse as an example of the new syntax.
One thing to note: while the Rust and TypeScript bindings use optional/
null fields, as that is the norm in those languages, Google's Python
bindings are not very Pythonic. Referencing an optional field that is
missing will yield the default value, and a separate HasField() call
is required, eg:
```
>>> from anki.stats_pb2 import CardStatsResponse as R
... msg = R.FromString(b"")
... print(msg.first_review)
... print(msg.HasField("first_review"))
0
False
```
* Move Trigger into its own file
* Try implement HandlerList
* Implement new input handler and handler-list
* Use new refocus HandlerList in TextColorButton
* Fix TextColorButton on windows
* Move ColorPicker to editor-toolbar
* Change trigger behavior of overwriteSurround
* Fix mathjax-overlay flushCaret
* Insert image via bridgeCommand return value
* Fix invoking color picker with F8
* Have remove format work even when collapsed
* Satisfy formatter
* Insert media via callback resolved from python
* Replace print with web.eval
* Fix python formatting
* remove unused function (dae)
* Clarify some comments
* Don't destructure insertion trigger
* Make superscript and subscript use domlib/surround
* Create new {Text,Highlight}ColorButton
* Use domlib/surround for textcolor
- However there's still a crucial bug, when you're breaking existing
colored span when unsurrounding, their color is not restored
* Add underline format to removeFormats
* Simplify type of ElementMatcher and ElementClearer for end users
* Add some comments for normalize-insertion-ranges
* Split normalize-insertion-ranges into remove-adjacent and remove-within
* Factor out find-remove from unsurround.ts
* Rename merge-mach, simplify remove-within
* Clarify some comments
* Refactor first reduce
* Refactor reduceRight
* Flatten functions in merge-ranges
* Move some functionality to merge-ranges and do not export
* Refactor merge-ranges
* Remove createInitialMergeMatch
* Finish refactoring of merge-ranges
* Refactor merge-ranges to minimal-ranges and add some unit testing
* Move more logic into text-node
* Remove most most of the logic from remove-adjacent
- remove-adjacent is still part of the "merging" logic, as it increases
the scope of the child node ranges
* Add some tests for edge cases
* Merge remove-adjacent logic into minimal-ranges
* Refactor unnecessary list destructuring
* Add some TODOs
* Put removing nodes and adding new nodes into sequence
* Refactor MatchResult to MatchType and return clear from matcher
* Inline surround/helpers
* Shorten name of param
* Add another edge case test
* Add an example where commonAncestorContainer != normalization level
* Fix bug in find-adjacent when find more than one nested nodes
* Allow comments for Along type
* Simplify find-adjacent by removing intermediate and/or curried functions
* Remove extend-adjacent
* Add more tests when find-adjacent finds by descension
* Fix find-adjacent descending into block-level elements
* Add clarifying comment to refusing to descend into block-level elements
* Move shifting logic into find-adjacent
* Rename file matcher to match-type
* Give a first implemention of TreeVertex
* Remove MatchType.ALONG
- findAdjacent now directly modifies the range
* Rename MatchType.MATCH into MatchType.REMOVE
* Implement a version of find-within that utilizies match-tree
* Turn child node range into a class
* Fix bug in new find-adjacent function
* Make all find-adjacent tests test for ranges
* Surrounding within farthestMatchingAncestor when available
* Fix an issue with negligable elements
- also rename "along" elements to "negligable"
* Add two TODOs to SurroundFormat interface
* Have a messy first implementation of the new tree-node algorithm
* Maintain whether formatting nodes are covered or within user selection
* Move covered and insideRange into TreeNode superclass
* Reimplement findAdjacent logic
* Add extension logic
* Add an evaluate method to nodes
* Introduce BlockNode
* Add a first evaluate implementation
* Add left shift and inner shift logic
* Implement SurroundFormatUser
* Allow pass in formatter, ascender and merger from outside
* Fix insideRange and covered switch-up
* Fix MatchNode.prototype.isAscendable
* Fix another switch-up of covered and insideRange...
* Remove a lot of old code
* Have surround functions only return the range
- I still cannot think of a good reason why we should return addedNodes
and removedNodes, except for testing.
* Create formatting-tree directory
* Create build-tree directory + Move find-above up to /domlib
* Remove range-anchors
* Move unsurround logic into no-splitting
* Fix extend-merge
* Fix inner shift being eroneusly returned as left shift
* Fix oversight in SplitRange
* Redefine how ranges are recreated
* Rename covered to insideMatch and put as fourth parameter instead of third
* Keep track of match holes and match leaves
* Rename ChildNodeRange to FlatRange
* Change signature of matcher
* Fix bug in extend-merge
* Improve Match class
* Utilize cache in TextColorButton
* Implement getBaseSurrounder for TextColorButton
* Add matchAncestors field to FormattingNode
* Introduce matchAncestors and getCache
* Do clearing during parsing already
- This way, you know whether elements will be removed before getting to
Formatting nodes
* Make HighlightColorButton use our surround mechanism
* Fix a bug with calling .removeAttribute and .hasAttribute
* Add side button to RemoveFormat button
* Add disabled to remove format side button
* Expose remove formats on RemoveFormat button
* Reinvent editor/surround as Surrounder class
* Fix split-text when working with insert trigger
* Try counteracting the contenteditable's auto surrounding
* Remove matching elements before normalizing
* Rewrite match-type
* Move setting match leaves into build
* Change editing strings
- So that color strings match bold/italic strings better
* Fix border radius of List options menu
* Implement extensions functionality
* Remove some unnecessary code
* Fix split range endOffset
* Type MatchType
* Reformat MatchType + add docs
* Fix domlib/surround/apply
* Satisfy last tests
* Register Surrounder as package
* Clarify some comments
* Correctly implement reformat
* Reformat with inactive eraser formats
* Clear empty spans with RemoveFormatButton
* Fix Super/Subscript button
* Use ftl string for hardcoded tooltip
* Adjust wording
This was inadvertently dropped in 478b3a53f1,
but AnkiWeb requires it.
In the future we will need to give these index pages a bit more thought,
as it's not very helpful to be exporting a creation function if we're
automatically mounting as the module is imported. Dropping the automatic
mounting would give us more flexibility, but currently that leads to
a FOUC in night mode, as the webview is revealed prior to a subsequent
web.eval() call being able to fire.
* avoid repinning Rust deps by default
* add id_tree dependency
* Respect intermediate child limits in v3
* Test new behaviour of v3 counts
* Rework v3 queue building to respect parent limits
* Add missing did field to SQL query
* Fix `LimitTreeMap::is_exhausted()`
* Rework tree building logic
https://github.com/ankitects/anki/pull/1638#discussion_r798328734
* Add timer for build_queues()
* `is_exhausted()` -> `limit_reached()`
* Move context and limits into `QueueBuilder`
This allows for moving more logic into QueueBuilder, so less passing
around of arguments. Unfortunately, some tests will require additional
work to set up.
* Fix stop condition in new_cards_by_position
* Fix order gather order of new cards by deck
* Add scheduler/queue/builder/burying.rs
* Fix bad tree due to unsorted child decks
* Fix comment
* Fix `cap_new_to_review_rec()`
* Add test for new card gathering
* Always sort `child_decks()`
* Fix deck removal in `cap_new_to_review_rec()`
* Fix sibling ordering in new card gathering
* Remove limits for deck total count with children
* Add random gather order
* Remove bad sibling order handling
All routines ensure ascending order now.
Also do some other minor refactoring.
* Remove queue truncating
All routines stop now as soon as the root limit is reached.
* Move deck fetching into `QueueBuilder::new()`
* Rework new card gather and sort options
https://github.com/ankitects/anki/pull/1638#issuecomment-1032173013
* Disable new sort order choices ...
depending on set gather order.
* Use enum instead of numbers
* Ensure valid sort order setting
* Update new gather and sort order tooltips
* Warn about random insertion order with v3
* Revert "Add timer for build_queues()"
This reverts commit c9f5fc6ebe87953c17a0c842990b009b5596c69c.
* Update rslib/src/storage/card/mod.rs (dae)
* minor wording tweaks to the tooltips (dae)
+ move legacy strings to bottom
+ consistent capitalization (our leech action still needs fixing,
but that will require introducing a new 'suspend card' string as the
existing one is used elsewhere as well)
* Fix field not being restored after Undo, if field also has focus
* Execute moveCaretToEnd after undoing a change
- Otherwise the caret might be placed in seemingly random positions
* Fix wording of comments
* Remove autofocus functionality of EditingArea
- instead await a tick in focusField
- We used the autofocus prop for the initial focus setting when opening the
editor. However it seems that awaiting tick in focusField also does the trick.
* Make eslint sort our imports
* fix missing deps in eslint rule (dae)
Caught on Linux due to the stricter sandboxing
* Remove exports-last eslint rule (for now?)
* Adjust browserslist settings
- We use ResizeObserver which is not supported in browsers like KaiOS,
Baidu or Android UC
* Raise minimum iOS version 13.4
- It's the first version that supports ResizeObserver
* Apply new eslint rules to sort imports
* Add componentHook functionality
* Register package NoteEditor
* Rename OldEditorAdapter to NoteEditor
* Expose instances in component-hook as well
* Rename NoteTypeButtons to NotetypeButtons
* Move PreviewButton initialization to BrowserEditor.svelte
* Remove focusInRichText
- Same thing can be done by inspecting activeInput
* Satisfy formatter
* Fix remaining rebase issues
* Add .bazel to .prettierignore
* Rename currentField and activeInput to focused{Field,Input}
* Move identifier to lib and registration to sveltelib
* Fix Dynamic component insertion
* Simplify editingInputIsRichText
* Give extra warning in svelte/svelte.ts
- This was caused by doing a rename of a files, that only differed in
case: NoteTypeButtons.svelte to NotetypeButtons.svelte
- It was quite tough to figure out, and this console.log might make it
easier if it ever happens again
* Change signature of contextProperty
* Add ts/typings for add-on definition files
* Add Anki types in typings/common/index.d.ts
* Export without .svelte suffix
It conflicts with how Svelte types its packages
* Fix left over .svelte import from editor.py
* Rename NoteTypeButtons to unrelated to ensure case-only rename
* Rename back to NotetypeButtons.svelte
* Remove unused component-hook.ts, Fix typing in lifecycle-hooks
* Merge runtime-require and register-package into one file
+ Give some preliminary types to require
* Rename uiDidLoad to loaded
* Fix eslint / svelte-check
* Rename context imports to noteEditorContext
* Fix import name mismatch
- I wonder why these issues are not caught by svelte-check?
* Rename two missed usages of uiDidLoad
* Fix ButtonDropdown from having wrong border-radius
* Uniformly rename libraries to packages
- I don't have a strong opinion on whether to name them libraries or
packages, I just think we should have a uniform name.
- JS/TS only uses the terms "module" and "namespace", however `package`
is a reserved keyword for future use, whereas `library` is not.
* Refactor registration.ts into dynamic-slotting
- This is part of an effort to refactor the dynamic slotting (extending
buttons) functionality out of components like ButtonGroup.
* Remove dynamically-slottable logic from ButtonToolbar
* Use DynamicallySlottable in editor-toolbar
* Fix no border radius on indentation button dropdown
* Fix AddonButtons
* Remove Item/ButtonGroupItem in deck-options, where it's not necessary
* Remove unnecessary uses of Item and ButtonGroupItem
* Fix remaining tests
* Fix relative imports
* Revert change return value of remapBinToSrcDir to ./bazel/out...
* Remove typings directory
* Adjust comments for dynamic-slottings
* Put PlainTextInput into its own directory
* Create a directory for RichTextInput
* Create editor-toolbar directory
* Move PreviewButton into editor-toolbar
* The time to refactor this is not quite yet here
* Create tag-editor directory
* Remove some of the uses of WithShortcut
* Remove all uses of WithShortcut from editor package
* Remove last uses of WithShortcut
* Fix typo
Unfortunately 5efaf5a4be broke the Svelte
language tools - presumably having paths outside of the repo is confusing
them.
As a plan B, the symlinks have been shifted to a single subdir. Along
with some exclusions in the VS Code config, this should allow VS Code
to continue to work out of the box, but the docs will need updating
to reflect the extra work required for PyCharm/IntelliJ.
+ fix svelte-check execution on a system without node installed. It
still throws up some errors that are presumably caused by our multiple
rootDirs - not sure if there's an easy way to work around that.
* Add _bytes methods for all methods in the backend
Expose get_note in qt/aqt/mediasrv.py
* Satisfy formatter
* Rename _bytes function to _raw and have them bytes as input
* Fix backend generation
* Use lib/proto/deckOptions in deck-options
* Add exposed_backend to qt/aqt/mediasrv.py
* Move some more backend methods to exposed_backend_list
* Use protobufjs for congrats and i18n
* Use protobufjs for completeTag
* Use protobufjs services in change-notetype
* Reorder post handlers in alphabetical manner
* Satisfy tests
* Remove unused collection methods
* Rename access_backend to raw_backend_request
* Use _vendor.stringcase instead of creating a new function
* Remove SKIP_UNROLL_OUTPUT
* Directly call _run_command in non _raw methods
* Remove TranslateString, ChangeNotetype and CompleteTag from SKIP_UNROLL_INPUT
* Remove UpdateDeckConfigs from SKIP_UNROLL_INPUT
* Remove ChangeNotetype from SKIP_UNROLL_INPUT
* Remove SKIP_UNROLL_INPUT
* Fix typing issue with translate_string
- Adds typing support for Protobuf maps in genbackend.py
* Do not emit convenience method for protobuf TranslateString
* Improve side margins in card info screen
* Improve top margin in deck options screen
* Hide revlog time of day on narrow screens
* Remove monospace for now (dae)
* Move some AddCards specific code to NoteCreator.svelte
* Add new strings for Toggling the Visual / HTML editor
* Set LabelContainer vertical-align to text-top
- Makes them look more centered
* Remove appendInParentheses helper
* Make all ts/*.html files include only module.js and module.css
* Move any JS from .html to index files
* Remove .html files from ts modules
* Remove Python with Starlark implemenation
* Remove reference to non-existing file
* Remove deck-option.html as well
* fix change-notetype screen (dae)
- fixes warnings about security issues in marked/markdown-it
- jsdoc is mostly unmaintained at this point, and we need to override
its dependencies manually
- typescript is still pinned
* Forbid inserting object and iframe tags via PlainTextInput
* Add optional browserMode parameter to Editor
* Create new ts modules for three editor instances
- note-creator for AddCards
- browser-editor for the editor in the Browser
- reviewer-editor for the EditCurrent
* Revert "Forbid inserting object and iframe tags via PlainTextInput"
This reverts commit ab90ae8194494d883a1863126496e2d8f332509e.
* Refactor browserMode to editorMode
* Move new editor variants inside /ts/editor directory
* Fix typo
* Avoid initial call of mirror-dom
* Disable updateFocus from OldEditorAdapter
* fixes IME input duplication bug
* Fix saving of latestLocation for ContentEditable
* Fix IME after calling placeCaretAfterContent
* Export other libraries from domlib/index.ts
* Remove dead code
+ Uncomment code which was mistakenly left commmented
* Use nested tables in revlog
This allows for centered rows, while still preserving internal
alignment.
* Fix hidden columns
* Replace inner tables with flexbox divs
* Replace revlog table with flexbox divs
* Replace flex-gap in revlog
Unsupported on iOS and Qt5.
* Move move-nodes logic into domlib
Refactor input-manager
Refactor out FocusTrap from EditingArea
Remove unnecessary selecting of node from surround
Add onInput interface to input-manager
Create MathjaxElement.svelte
- This should contain all the setup necessary for displaying
<anki-mathjax> elements in the rich text input
- Does not contain setup necessary for Mathjax Overlay
Deal with backwards deletion, when caret inside anki-mathjax
Set mathjax elements contenteditable=false
Do not undecorate mathjaxx element on disconnect
- Fixes issues, where Mathjax might undecorate when it is moved into a
different div
Add framed element custom element
Introduce iterateActions to allow global hooks for RichTextInput
Remove some old code
Deal with deletion of frame handles
Make Anki frame and frame handles restore each other
Make FrameElement restore its structure upon modification
Frame and strip off framing from MathjaxElement automatically
Move FrameHandle to separate FrameStart/FrameEnd
Refactor FrameHandle
Set data-frames on FrameElement
Fix logic error connected to FrameElement
Communicate frameHandle move{in,out} to anki-mathjax
Clear selection when blurring ContentEditable
Make sure frame is destroyed when undecorating Mathjax
Use Hairline space instead of zeroWidth
- it has better behavior in the contenteditable when placing the caret
via clicking
Allow detection of block elements with `block` attribute
- This way, anki-mathjax block="true" will make field a
field be recognized to have block content
Make block frame element operater without handles
- Clicking on the left/right side of a block mathjax will insert a br
element to that side
When deleting, remove mathajax-element not just image
Update MathjaxButtons to correctly show block state
SelectAll when moving into inline anki mathjax
Remove CodeMirror autofocus functionality
Move it to Mathjaxeditor directly
Fix getRangeAt throwing error
Update older code to use cross-browser
Fix issue with FrameHandles not being properyly removed
Satisfy formatting
Use === instead of node.isSameNode()
Fix issue of focusTrap not initialized
* Fix after rebasing
* Fix focus not being moved to first field
* Add documentation for input-manager and iterate-actions
* Export logic of ContentEditable to content-editable
* Fix issue with inserting newline right next to inline Mathjax
* Fix reframing issue of Mathjax Svelte component
* Allow for deletion of Inline Mathjax again
* Rename iterate-actions to action-list
* Add copyright header
* Split off frame-handle from frame-element
* Add some comments for framing process
* Add mising return types
* Add thousands comma separator for card counts graph
* Fix Answer Buttons graph's tooltip
Changes to the "times pressed" heading
* Shows the percent of that button out of all the presses
* Comma separates total on thousands
* Update CONTRIBUTERS
* Wider spacing for graph tables
* Switch to locale-based stats numbers
* Update CONTRIBUTORS
Wrong email?
* Fix counts graph on narrow devices
Graph and table now align in a column when the device's screen is narrow. Columns widths are bounded to not get too wide
* Rename toLocaleXXX functions
* toLocaleNumber -> localizedNumber
* toLocaleString -> localizedDate
Also cleans up sketchy "card counts" table formatting
* Localize more numbers
Uses locale-based rounding for more numbers now
* Localize graph axis ticks
* Fix future-due graph tooltip
* avoid div by zero (dae)
Ignoring NaN in localizedNumber() could potentially mask a mistake
in the future - better to explicitly handle the invalid case at the
source instead.
* Prevent unwanted <div> from being left behind when clearing field
* Use event.currentTarget instead of 'this'
* Check if event.data is empty for better performance
* Change order of conditions for better performance
* Fix media playback not terminating when previewer is closed
https://forums.ankiweb.net/t/anki-2-1-50-beta/15608/78
* Fix _on_preview_closed being called twice unnecessarily
The function was being called twice when the preview button is clicked
while the previewer is open.
* Fix console error caused by leftover code
The following error was shown in the console when closing previewer:
`Uncaught TypeError: Cannot read property 'classList' of null`
* Toggle state of preview button via 'active' prop
* Preload external css files to prevent flash of unstyled content
This is an implementation of the approach mentioned in the commit
message of 46b85d5.
* Tweak max_age value for css files
Ensure that css preloading works even on a slow PC.
* Fix steps being mistaken for seconds
* Cap steps at `u32::max` seconds
* Fix overflow of steps in Rust
* Prevent overflow of `IntervalKind`
* Prevent overflow in `revlod/mod.rs`
Also replace some `as` with `from` and `try_from` as is recommended to
highlight potential issues.
* Ensure v2 doesn't store overflowing revlog ivls
* Lower steps cap in deck options
Whereas large card intervals are converted to days, revlog intervals use
i32s to store large numbers of seconds.
* Format
* 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 3a4511042da7083a52d67b58550b13d873dcbea5.
* 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>
* 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
* 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
* 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>
* 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>
* 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 f42beee45c27dba9433d76217fb583b117fb5231.
* Final cleanup
* Refine padding/gutter
* 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
* 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)
* 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
* 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
* 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`
* 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
* 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>
* 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
* 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)
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)
* 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
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.
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;
};
...
- 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.
* 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
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 e1d4292ce3979e7b7ee21bf3951b8a462d45c29c.
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 0a96776a475e9901c1f9f3407c726d1d002fb9ef.
* move withCollapsedWhitespace back to i18n/utils
* Add back /ts as in rootDirs
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
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.
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.
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.
typescript and bootstrap have been pinned for now:
https://github.com/ankitects/anki/issues/1386https://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