* setup mask editor in note editor
- add image on mask button click (only one time)
- show hide add button for io on notetype change
- hide field in io notetype
- icon for toggle
and replace image
* add update io notes
* Tidy up i/o notetype check and fix error
- Make it a method on editor
- Use .get(), because the setting doesn't exist on older notetypes
- Pass the bool value into the ts code, instead of the enum
* reset io page after adding
* remove adjust function & add target for mask editor
* handle browse mode & merged sidetoolbar and toptoolbar to toolbar
* fix: shape, button click in browse, dropdown menu
* add arrow to add button
* store for handling visiblity of maskeditor
- remove update button in edit mode, implement autoupdate
* update var name
* simplify store
* eslint-plugin-svelte3 -> eslint-plugin-svelte
The former is deprecated, and blocks an update to Svelte 4.
Also drop unused svelte2tsx and types package.
* Drop unused symbols code for now
It may be added back in the future, but for now dropping it will save
200k from our editor bundle.
* Remove sass and caniuse-lite pins
The latter no longer seems to be required. The former was added to
suppress deprecation warnings when compiling the old bootstrap version
we have pinned. Those are hidden by the build tool now (though we really
need to address them at one point: https://github.com/ankitects/anki/issues/1385)
Also removed unused files section.
* Prevent proto compile from looking in node_modules/@types/sass
When deps are updated, tsc aborts because @types/sass is a dummy package
without an index.d.ts file.
* Filter Svelte warnings out of ./run
* Update to latest Bootstrap
This fixes the deprecation warnings we were getting during build:
bootstrap doesn't accept runtime CSS variables being set in Sass, as
it wants to apply transforms to the colors.
Closes#1385
* Start port to Svelte 4
- svelte-check tests have a bunch of failures; ./run works
- Svelte no longer exposes internals, so we can't use create_in_transition
- Also update esbuild and related components like esbuild-svelte
* Fix test failures
Had to add some more a11y warning ignores - have added
https://github.com/ankitects/anki/issues/2564 to address that in the
future.
* Remove some dependency pins
+ Remove sass, we don't need it directly
* Bump remaining JS deps that have a current semver
* Upgrade dprint/license-checker/marked
The new helper method avoids marked printing deprecation warnings to
the console.
Also remove unused lodash/long types, and move lodahs-es to devdeps
* Upgrade eslint and fluent packages
* Update @floating-ui/dom
The only dependencies remaining are currently blocked:
- Jest 29 gives some error about require vs import; may not be worth
investigating if we switch to Deno for the tests
- CodeMirror 6 is a big API change and will need work.
* Roll dprint back to an earlier version
GitHub dropped support for Ubuntu 18 runners, causing dprint's artifacts
to require a glibc version greater than what Anki CI currently has.
* Fix MathJax editor not closing when changing notes via shortcut
Another commit will remove the on:blur handler set for <MathjaxEditor>,
in which case the function will also be called when changing notes with
a mouse click.
* Don't close MathJax editor on blur event
Closing MathJax editor on a blur event caused it to close even when
it should not.
e.g.
- when switching to another application
- when right-clicking to bring up the context menu
- when clicking on the empty space around CodeMirror
* Fix shortcut not being unregistered when Plain/RichTextBadge is detroyed
This fixes an issue where, if the "Show HTML by default" option of
fields located at the same position in two notetypes have different
values, switching between those notetypes during an editor session
would cause the keyboard shortcut (Ctrl+Shift+X) to no longer function
correctly thereafter.
* Don't restore fields' state if notetype has been modified
This fixes an issue where editor fields behave incorrectly after
opening the 'Fields' dialog and customizing the notetype. An example
of incorrect behavior is that after adding a new field and closing
the dialog, the added field would display both richtext input and
plaintext input, regardless of the options.
* Rename type, variable and function
- Apply suggestions from code review
- Also use optional chaining instead of non-null assertion
Prettier by default tries to preserve whitespace around inline tags,
which can prevent problems such as a space before the period in
'<a>text</a>.':
https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting
Unfortunately only standard HTML block elements are excluded from this
behaviour, so all of our Svelte components are treated the same way, even
if they are block-based, or used in a way where the extra whitespace
doesn't matter. This makes the code somewhat harder to read.
Changing this option does carry the risk that rogue spaces will creep
into our UI in the future as code is formatted, but as there don't appear
to be any such issues with this initial reformat, I think the improved
readability may justify the relatively small risk.
* Refactor plain/rich text input toggling code; fix focus loss
Fix:
- Issue where field loses focus when plain/rich text input is closed
Refactoring:
- Call refocus() inside the reactive statement in
Plain/RichTextInput.svelte to eliminate the need for polling
with requestAnimationFrame
- Introduce 'Flag' class
- Move 'on:toggle' handlers from inline to functions defined in
the <script> section for better readability
* Improve code clarity based on feedback from code review
- Rename method and add comment to it
- Add 'private' access modifier to property
* Fix MathJax editor sometimes not properly sized
Also fix an issue where when 'Reduce motion' is enabled, a popover
appears momentarily out of position and then shifts to the correct
position.
* Fix MathJax editor sometimes getting cut off
* Change max-width of MathJax editor
* Revert "Fix open editors getting carried over to different notetypes (#2393)"
This reverts commit bf5bcd3f52.
* Improved fix for open editors getting carried over to different notetypes
* Run ninja format
* Fix open editors getting carried over to different notetypes
* Fix first field not getting automatically focused
* Fix collapsibles not transitioning in reduced motion mode
* Fix editor taking a longer time to start when reduced motion is enabled
If we don't transition, the editor actually takes considerably longer to create all the fields.
* Fix fields not collapsing when notetype is loaded
* Remove Pane components and use Collapsible for TagEditor
* Update translations
* Give TagEditor border and focus outline
* Use ScrollArea from #2248 for fields
* Refactor ScrollArea
* Fix error caused by calling bridgeCommand when it's not available
* Make sure tag editor fills whole width of container
which is important for the CSV import page.
* Update NoteEditor.svelte
* Add back removed ftl strings
* Fix tests (dae)
* Create widget gallery dialog
* Add WidgetGallery to debug dialog
* Use enum for its intended purpose
* Rename "reduced-motion" to "reduce-motion"
* Add another border-radius value
and make former large radius a bit smaller.
* Revamp preferences, add minimalist mode
Also:
- create additional and missing widget styles and tweak existing ones
- use single profile entry to set widget styles and reduce choices to Anki and Native
* Indent QTabBar style definitions
* Add missing styles for QPushButton states
* Fix QTableView background
* Remove unused layout from Preferences
* Fix QTabView focused tab style
* Highlight QCheckBox and QRadioButton when focused
* Fix toolbar styles
* Reorder preferences
* Add setting to hide bottom toolbar
* Move toolbar settings above minimalist modes
* Remove unused lines
* Implement proper full-screen mode
* Sort imports
* Tweak deck overview appearance in minimalist mode
* Undo TitledContainer changes
since nobody asked for that
* Remove dynamic toolbar background from minimalist mode
* Tweak buttons in minimalist mode
* Fix some issues
* Reduce theme check interval to 5s on Linux
* Increase hide timer interval to 2s
* Collapse toolbars with slight delay when moving to review state
This should ensure the bottom toolbar collapses too.
* Allow users to make hiding exclusive to full screen
* Rename full screen option
* Fix hide mode dropdown ignoring checkbox state on startup
* Fix typing issue
* Refine background image handling
Giving the toolbar body the main webview height ensures background-size: cover behaves exactly the same.
To prevent an override of other background properties, users are advised to only set background-images via the background-image property, not the background shorthand.
* Fix top toolbar getting huge when switching modes
The issue was caused by the min-height hack to align the background images. A call to web.adjustHeightToFit would set the toolbar to the same height as the main webview, as the function makes use of document.offsetHeight.
* Prevent scrollbar from appearing on bottom toolbar resize
* Cleanup
* Put review tab before editing; fix some tab orders
* Rename 'network' to 'syncing'
* Fix bottom toolbar disappearing on UI > 100
* Improve Preferences layout by adding vertical spacers to the bottom
also make the hiding of video_driver and its label more obvious in preferences.py.
* Fix bottom toolbar animating on startup
Also fix bottom toolbar not appearing when unchecking hide mode in reviewer.
* Hide/Show menubar in fullscreen mode along with toolbar
* Attempt to fix broken native theme on macOS
* Format
* Improve native theme on other systems by not forcing palette
with the caveat that theme switching can get weird.
* Fix theme switching in native style
* Remove redundant condition
* Add back check for Qt5 to prevent theme issues
* Add check for macOS before setting fusion theme
* Do not force scrollbar styles on macOS
* Remove all of that crazy theme logic
* Use canvas instead of button-bg for ColorRole.Button
* Make sure Anki style is always based on Fusion
otherwise we can't guarantee the same look on all systems.
* Explicitly apply default style when Anki style is not selected
This should fix the style not switching back after it was selected.
* Remove reduncant default_palette
* Revert 8af4c1cc2
On Mac with native theme, both Qt5 and Qt6 look correct already. On
the Anki theme, without this change, we get the fusion-style scrollbars
instead of the rounded ones.
* Rename AnkiStyles enum to WidgetStyle
* Fix theme switching shades on same theme
* Format
* Remove unused placeholderText
that caused an error when opening the widget gallery on Qt5.
* Check for full screen windowState using bitwise operator
to prevent error in Qt5.
Credit: https://stackoverflow.com/a/65425151
* Hide style option on Windows
also exclude native option from dropdown just in case.
* Format
* Minor naming tweak
* Remove 'ResizableImage.svelte'
Rather than having a svelte file that just sets global styles, it's
better to set those in a (s)css file.
* Fix and refactor image size constraints
- Fixes https://forums.ankiweb.net/t/2-1-56-image-size-problem-in-editor/26207
- Use :host-context() to switch image styles instead of toggling CSS
variables.
* Fix toolbar buttons for image overlay sometimes being cut off
* Give webviews a slide-in animation
if reduced motion isn't set.
* Auto-hide toolbar in review mode
moving the mouse above the main webview expands the toolbar. When the mouse leaves the toolbar, it will collapse after a delay of 2s.
* Save some space on bottom toolbars
* Use props for all hard-coded transition durations
and decrease most commonly used duration (200ms) to 150ms.
* Move auto-hide logic into ToolbarWebView
and handle auto-hide specific events in the respective webview subclasses.
* Fix typing issues
* Fix flickering issue
* Add auto_hide_toolbar opt-in to preferences
* Rename hide_toolbar to collapse_toolbar
to better describe the dock-like behaviour.
* Rename setting to minimize_distractions
* Reduce calls to pm in eventFilter
* Run formatter
* Revert setting title to something more specific
* Increase default animation time to 180ms
* Inset toolbar in review mode
when auto-hide is not enabled.
* Use card background on toolbar and add glass effect
* Use flatten/elevate over inset/outset
* Use flatten/elevate over inset/outset
* Update toolbar.py
* Fix toolbar background delay
* Tweak styles
* Use "collapse" instead of "auto-hide"
* Fix background misalignment in collapse mode
* Do not collapse toolbar when pointer is outside MainWebView
* Reduce hide_timer interval to 1000ms
* Use CSS to hide toolbar instead of setting webview height
* Add guard to prevent backdrop-filter: blur on Qt 5.14
* Apply transition to body instead of toolbar
to not complicate things for #2301.
* Fix Qt 5.14 and apply guard globally
* Fix background image scaling difference
* Tweak preference wording (dae)
* Add 'placement' property
* Extract logic for moving text node into instance method
... so that it can be used elsewhere.
* Add writable store to indicate whether composition session is active
* Work around issue with entering text around MathJax via IME
* Make get() called only once while composition session is active
Appears to have regressed in #2071. I'd used 'inherit' so that the default
editable styling would impose a 100% limit, but it appears that variable
interpolation prevents the parent styling from being applied.
When a pop-up menu was closed by clicking on an empty space
outside the fields, the variable controlling the display state
was not changed, causing the pop-up menu to flash momentarily
the next time a field was focused.
* Fix MathJax popup fails to appear when adding MathJax via Fx button
* Revert "Fix MathJax popup fails to appear when adding MathJax via Fx button"
This reverts commit 11115f59bcbde22bbc0448bfd6b86e887a8a56a7.
* Fix MathJax popup fails to appear when adding MathJax via Fx button
Use setTimeout() according to the PR review
* Persist collapsed- and field states with SessionOptions object
* Format types.ts
* Replace format function with f-string
* Give setters more descriptive parameter names
* Do not use default prefix for descriptions and fonts
since they are not meant to be changed via Svelte.
* Do not include oldIdx in Select change event
I included it due to confusion about the variable names in the Change Notetype components.
* Remove redundant on:change listener from NotetypeSelector
* Use Select component in Change Notetype MapperRow (again)
* Remove redundant --cols and --col-size definitions
Bootstrap divides rows into columns of equal width by default.
* Add highlight to active DropdownItem
* Remove bootstrap dropdown item styling
* Fix JS error on dropdown accept action
cause: When closing the dropdown, buttonRef was removed before the callback in setTimeout was run.
* Give deck browser table an elevated container look
* Tweak colors of elevated containers (e.g. in deck options)
* Prepare editor fields for custom backgrounds
* Tweak field margin and add explanatory comment
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
* Prevent global focus border on tag-input
* Fix margin issues with tag editor
* Remove redundant autocomplete call
that caused the addition of an empty tag when tag suggestions were selected with the Enter key.
* Prevent input text from overlapping with newly added tags
... at least when they're selected from the autocomplete list via mouse. If they're selected via keyboard, there's still an overlapping issue.
* Fix error on updateSuggestions
* Hide empty tag
* Make double-click to collapse/expand translatable
* Reduce font size of answer button indicators
* Increase padding of browser rows with ResizeToContents on vertical header
* Remove 0.8 scale factor for dropdown item font-size
* Remove font-size prop entirely from DropdownItem
* Revert "Remove font-size prop entirely from DropdownItem"
This reverts commit bb0a158f96183cca74e198867070c2f99af04dc4.
* Remove hard-coded Python font sizes
* Move font size and scrollbar into _root-vars.scss
* Revert editor size variable to 1.6
* Fix icon alignment
* Fix checkbox alignment for dropdown items
* Remove unused classes from Tag.svelte
* Revert "Increase padding of browser rows with ResizeToContents on vertical header"
This reverts commit 77bfc854ba140dd99aae98efcdd4af7052615fa6.
* Remove option to set font size of browser entries
* Add setting for browser row padding to preferences
* Revert "Add setting for browser row padding to preferences"
This reverts commit 75c59da65a1028e2caa3c48b247f99825c1b0b6c.
* Revert "Remove option to set font size of browser entries"
This reverts commit a543783d8ea079f39b7ae445152573c96be29841.
* Replace autoPlacement with flip
* Remove logic made redundant by use of flip()
* Edit preferred placement on components using WithFloating
* Rename placement to preferredPlacement
* Set "bottom" as default placement and remove redundant declarations