* 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)
* 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
* 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>
* 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
* 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)
* 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
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.
Contains the shadow root, and references to the styles.
Is ignorant of Editable.
Is necessary, so our we editable.scss does not need to contain
information about Codable, ImageHandle or all those other things which
have nothing to do with Editable
- Means add-on authors should not need to inject any code in their build
- Should be more flexible - we can export multiple libraries if we wish,
and don't have to worry about require() being clobbered by old add-ons.