Commit graph

779 commits

Author SHA1 Message Date
Henrik Giesel
042f953f4f Fix editor dropdowns (#1649) 2022-02-08 14:13:55 +10:00
Henrik Giesel
fe985644e9 Fix CommandIconButton (#1648)
- It did not respect shortcuts
2022-02-08 14:13:18 +10:00
Henrik Giesel
8c21b74ece Make sure initial comments are preserved in HTML editor (#1647) 2022-02-08 14:07:09 +10:00
Henrik Giesel
5345ecbc0c Fix field not restored if active (#1639)
* 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.
2022-02-05 15:58:31 +10:00
Henrik Giesel
9f4f3d59d7 Fix CodeMirror retaining history of unrelated notes (#1640) 2022-02-04 18:40:50 +10:00
Henrik Giesel
fff0bd6e55 Use eslint for sorting our imports (#1637)
* 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
2022-02-04 18:36:34 +10:00
Henrik Giesel
90188f2588 Improved add-on extension API (#1626)
* 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
2022-02-03 14:52:11 +10:00
Hikaru Y
eebc97734b Fix field content overflowing its container (#1618) 2022-01-25 10:35:13 +10:00
Henrik Giesel
9c409e1bcf Separate input components into their own directories / Remove WithShortcut (#1613)
* 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
2022-01-24 11:43:09 +10:00
Henrik Giesel
97a0c06eae Add _raw methods for all methods in the backend (#1594)
* 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
2022-01-21 21:32:39 +10:00
Henrik Giesel
0450e209d5 Fix the caret flushing behavior when moving out of a Mathjax element (#1605)
* Fix the caret flushing behavior when moving out of a Mathjax element

* Fix typing issue and add docs for ContentEditableAPI
2022-01-19 10:17:53 +10:00
Henrik Giesel
9ed42d2bac Remove individual .html files + other refactorings (#1588)
* 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)
2022-01-16 15:05:35 +10:00
Henrik Giesel
f5ecf063a3 Split/Merge editor.py for its three use cases (#1581)
* 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
2022-01-12 14:51:43 +10:00
Henrik Giesel
d5211556cd Fix IME input after tab (#1584)
* 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
2022-01-12 08:39:41 +10:00
Henrik Giesel
d3ce4d16b9 Use default colors for CodeMirror in light theme Anki (#1578)
Refactor PlainTextInput

Put CodeMirror themes into variables
2022-01-10 12:51:50 +10:00
Henrik Giesel
5fb47df0e3 Small Tag editor fixes (#1580)
* Adjust height of TagInputs to not switch when changing mode

* Hide scrollbar on tag suggestions when not necessary
2022-01-08 11:48:17 +10:00
Henrik Giesel
e07a5f2a77 Reset .style.width when resizing images (#1579) 2022-01-08 11:47:12 +10:00
Henrik Giesel
fcd47371dc Fix some Mathjax issues (#1547)
* 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
2022-01-08 11:46:01 +10:00
Hikaru Y
8bb33f4ef1 Fix some issues with closing previewer (#1563)
* 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
2021-12-20 20:23:50 +10:00
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
Hikaru Y
cacb49f81d Fix custom CSS not being applied to scrollbars in night mode (#1525) 2021-12-05 08:20:42 +10:00
Henrik Giesel
b4772f47d1 Fix focus lost after adding note if non-sticky (#1523) 2021-12-03 21:41:12 +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
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
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
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
Henrik Giesel
d654a57a90 Set "no-non-null-assertion: off" by default (#1475) 2021-11-04 11:42:51 +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
Damien Elmes
eee17476e3 fix deprecation warning in latest svelte-preprocess 2021-10-26 08:43:02 +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
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
Henrik Giesel
ac92155a8e Put sass into repo directory (#1409)
Fix Sass build
2021-10-09 10:25:03 +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
7cc3b1816c fix invalid arg to ButtonGroup revealed by typing fix 2021-10-07 21:33:15 +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
9b994ac537 silence execCommand deprecation warnings for now 2021-09-29 11:36:37 +10: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
222da3912a Add ChangeTimer.prototype.fireImmediately
so Mathjax is saved when exiting editor prematurely
2021-09-16 14:47:05 +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
05cf123959 Apply specific CSS to Mathjax CodeMirror 2021-09-15 13:46:04 +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
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
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
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
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
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
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
7162a9b961 Do not start ImageHandle for images with [data-anki] 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
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
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
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
deb572e637 Rename tagEditor tag-editor.ts 2021-09-09 15:38:04 +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
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
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
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
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
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