From 3642dc62453757c9782b508444b4cd74588f3c99 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 5 Sep 2022 09:20:00 +0200 Subject: [PATCH] Use WithFloating for MathjaxOverlay (#2011) * Allow passing in reference into WithFloating as prop * Fix WithAutocomplete * Fix WithFloating for MathjaxOverlay * Add resize-store * Allow passing debug=True to jest_test for debugger support (#2013) * Disable auto-closing of HTML tags https://forums.ankiweb.net/t/set-html-editor-as-a-default-editor-instead-of-visual-editor/20988/3 Closes #1963 * Add slight margin to MathjaxEditor * Enable passing offset and shift to WithFloating * Hide overflow of mathjax editor * Add automatic hide functionality to sveltelib/position * Last polishes for Surrounder class (#2017) * Make private properties in Surrounder truly private * Fix remove logic of Surrounder * No reason for toggleTriggerRemove to be async * Allow using alt-shift to set all remove formats but this one * modifyFormat => updateFormat * Fix formatting * Fix field descriptions blocking cursor from being set (#2018) - happens when focus is in HTML editor * Remove hiding functionality again until it's really useful * Add support for autoPlacement * Implement new WithFloating that supports manually calling position() * Implement hide mechanisms * Add option in math dropdown to toggle MathJax rendering (#2014) * Add option in math dropdown to toggle MathJax rendering Closes #1942 * Hackily redraw the page when toggling MathJax * Add Fluent string * Default input setting in fields dialog (#1987) (kleinerpirat) * Introduce field setting to use plain text editor by default (kleinerpirat) * Remove leftover function from #1476 * Use boolean instead of string * Simplify clear_other_field_duplicates * Convert plain text key to camelCase * Move HTML item below the existing checkbox, instead of to the right (dae) Showing it on the right is more space efficient, but feels a bit cluttered IMHO. * Fix not being able to scroll when mouse hovers PlainTextInput (#2019) * Remove overscroll-behavior: none for * (all elements) * Revert "Remove overscroll-behavior: none for * (all elements)" This reverts commit 189358908cecd03027e19d8fe47822735319ec17. * Use body instead of *, but keep CSS rule * Unify two CSS rules * Remove console.logs * Reposition mathjax menu on switching between inline/block * Implement WithOverlay * Implement FloatingArrow * Display overlay with padding and brighter background * Rename to MathjaxOverlay * Simplify MathjaxOverlay component overall * Rename ImageHandle to image overlay * Generally fix ImageOverlay again * Increase z-index of StickyContainer * Fix setting block or inline on mathjax * Add reasons in closing-{click,keyup} * Have both WithFloating and WithOverlay use a simple show flag instead of a store * Remove subscribe-trigger * Fix clicking from one mathjax element to another * Check before executing cleanup * Do not wait for elements to mount before slotting in With{Floating,Overlay} * Allow using reference slot for WithFloating and WithOveray * Add inline argument to options * Add support for inline slot in WithOvelay * Use WithFloating for RemoveFormatButton * Remove last uses of DropdownMenu and WithDropdown * Remove all of the bootstrap dropdown components * Fix closing behavior of several buttons and ImageOverlay * Increase popover padding to 6px * Find a different way to create some padding at the bottom of the fields ...before the tag editor @kleinerpirat I think is what this css what trying to achieve? * Satisfy tests * Use removeStyleProperties in ImageOverlay * Use notify function in WithOverlay and WithFloating * Do not use portal for WithFloating and WithOverlay Allows for scrolling * Set hidden to default false in Rich/Plain TextInput * Reset handle when changing mathjax elements via click * Restrict size of empty mathjax image * Prevent sticky labels from obscuring menus * Remove several overflow-hidden * Fix empty string being falsy bug when editing mathjax * Do not import portal anymore * Use { reason, originalEvent } instead of symbol as update to modified event store * Fix closing behavior of image overlay (do not close after resize) * Simplify Collapsible * Use removeStyleProperties in Collapsible * Satisfy eslint * Fix latex shortcuts being mounted * Fix mathjax overlay not focusable in first field * Neither hide image overlay on escaped * Fix Block ButtonDropdown wrapping * Bring back portal to fix tag editor --- ts/components/ButtonDropdown.svelte | 45 ---- ts/components/Collapsible.svelte | 126 +++------ ts/components/DropdownItem.svelte | 8 - ts/components/DropdownMenu.svelte | 39 --- ts/components/FloatingArrow.svelte | 38 +++ ts/components/IconButton.svelte | 18 -- ts/components/Popover.svelte | 6 +- ts/components/StickyContainer.svelte | 2 +- ts/components/WithDropdown.svelte | 112 -------- ts/components/WithFloating.svelte | 226 ++++++++++------ ts/components/WithOverlay.svelte | 159 ++++++++++++ ts/components/WithState.svelte | 2 +- ts/deck-options/BUILD.bazel | 1 + ts/deck-options/RevertButton.svelte | 42 +-- ts/deck-options/SaveButton.svelte | 79 +++--- ts/deck-options/icons.ts | 2 +- ts/editable/Mathjax.svelte | 9 +- ts/editable/mathjax-element.ts | 2 +- ts/editor/CodeMirror.svelte | 14 +- ts/editor/EditorField.svelte | 26 +- ts/editor/FieldDescription.svelte | 3 +- ts/editor/Fields.svelte | 12 +- ts/editor/FieldsEditor.svelte | 7 - ts/editor/HandleBackground.svelte | 15 +- ts/editor/HandleControl.svelte | 4 +- ts/editor/HandleLabel.svelte | 10 +- ts/editor/HandleSelection.svelte | 73 ------ ts/editor/LabelContainer.svelte | 2 +- ts/editor/NoteEditor.svelte | 10 +- ts/editor/editor-toolbar/BlockButtons.svelte | 155 ++++++----- .../HighlightColorButton.svelte | 6 +- ts/editor/editor-toolbar/LatexButton.svelte | 42 ++- .../editor-toolbar/RemoveFormatButton.svelte | 51 ++-- .../editor-toolbar/TextColorButton.svelte | 6 +- ts/editor/editor-toolbar/icons.ts | 9 +- ts/editor/image-overlay/FloatButtons.svelte | 19 +- ...ImageHandle.svelte => ImageOverlay.svelte} | 123 ++++----- ts/editor/image-overlay/index.ts | 4 +- .../mathjax-overlay/MathjaxButtons.svelte | 29 +-- .../mathjax-overlay/MathjaxEditor.svelte | 28 +- .../mathjax-overlay/MathjaxHandle.svelte | 186 ------------- ts/editor/mathjax-overlay/MathjaxMenu.svelte | 91 ------- .../mathjax-overlay/MathjaxOverlay.svelte | 244 ++++++++++++++++++ ts/editor/mathjax-overlay/index.ts | 4 +- .../plain-text-input/PlainTextInput.svelte | 8 +- .../rich-text-input/RichTextInput.svelte | 8 +- ts/lib/typing.ts | 1 + ts/sveltelib/closing-click.ts | 51 ++-- ts/sveltelib/closing-keyup.ts | 16 +- ts/sveltelib/event-predicate.d.ts | 4 + ts/sveltelib/event-store.ts | 2 +- ts/sveltelib/portal.ts | 9 +- ts/sveltelib/position.ts | 111 -------- ts/sveltelib/position/auto-update.ts | 57 ++++ ts/sveltelib/position/index.ts | 0 ts/sveltelib/position/position-algorithm.d.ts | 12 + ts/sveltelib/position/position-floating.ts | 125 +++++++++ ts/sveltelib/position/position-overlay.ts | 67 +++++ ts/sveltelib/resize-store.ts | 45 ++++ ts/sveltelib/subscribe-trigger.ts | 44 ---- ts/sveltelib/toggleable.ts | 15 +- ts/sveltelib/tsconfig.json | 8 +- ts/tag-editor/TagEditor.svelte | 3 +- ts/tag-editor/WithAutocomplete.svelte | 18 +- .../TagsSelectedButton.svelte | 13 +- 65 files changed, 1405 insertions(+), 1301 deletions(-) delete mode 100644 ts/components/ButtonDropdown.svelte delete mode 100644 ts/components/DropdownMenu.svelte create mode 100644 ts/components/FloatingArrow.svelte delete mode 100644 ts/components/WithDropdown.svelte create mode 100644 ts/components/WithOverlay.svelte delete mode 100644 ts/editor/HandleSelection.svelte rename ts/editor/image-overlay/{ImageHandle.svelte => ImageOverlay.svelte} (75%) delete mode 100644 ts/editor/mathjax-overlay/MathjaxHandle.svelte delete mode 100644 ts/editor/mathjax-overlay/MathjaxMenu.svelte create mode 100644 ts/editor/mathjax-overlay/MathjaxOverlay.svelte create mode 100644 ts/sveltelib/event-predicate.d.ts delete mode 100644 ts/sveltelib/position.ts create mode 100644 ts/sveltelib/position/auto-update.ts create mode 100644 ts/sveltelib/position/index.ts create mode 100644 ts/sveltelib/position/position-algorithm.d.ts create mode 100644 ts/sveltelib/position/position-floating.ts create mode 100644 ts/sveltelib/position/position-overlay.ts create mode 100644 ts/sveltelib/resize-store.ts delete mode 100644 ts/sveltelib/subscribe-trigger.ts diff --git a/ts/components/ButtonDropdown.svelte b/ts/components/ButtonDropdown.svelte deleted file mode 100644 index 0a3ebe0c0..000000000 --- a/ts/components/ButtonDropdown.svelte +++ /dev/null @@ -1,45 +0,0 @@ - - - - -
- -
-
- - diff --git a/ts/components/Collapsible.svelte b/ts/components/Collapsible.svelte index 22396e11d..3fe987267 100644 --- a/ts/components/Collapsible.svelte +++ b/ts/components/Collapsible.svelte @@ -3,105 +3,53 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> -
-
- -
+
+
- - diff --git a/ts/components/DropdownItem.svelte b/ts/components/DropdownItem.svelte index 0c8325a5e..8137a3270 100644 --- a/ts/components/DropdownItem.svelte +++ b/ts/components/DropdownItem.svelte @@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->