Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(quick-edit): move mobile toolbar to the bottom
Elian Doran73a4a7325ba6
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.css b/apps/client/src/widgets/dialogs/PopupEditor.cssindex 83b9a69cc3..d7eb7fef18 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.css+++ b/apps/client/src/widgets/dialogs/PopupEditor.css@@ -94,6 +94,14 @@ body.mobile .modal.popup-editor-dialog .modal-dialog {.modal.popup-editor-dialog .modal-body {padding: 0;height: 75vh;+ overflow: hidden;+ display: flex;+ flex-direction: column;+}++.modal.popup-editor-dialog .popup-editor-scroll {+ flex: 1 1 auto;+ min-height: 0;overflow: auto;display: flex;flex-direction: column;@@ -138,13 +146,13 @@ body.mobile .modal.popup-editor-dialog .modal-dialog {margin-block: 0;}-/* The body is a fixed-height column, and the mobile rule that lets the fields shrink (to give the- editor room under the keyboard) collapses them to nothing on a note taller than the dialog. */+/* The scrolling column is fixed-height, and the mobile rule that lets the fields shrink (to give+ the editor room under the keyboard) collapses them to nothing on a note taller than the dialog. */body.mobile #root-widget:not(.virtual-keyboard-opened) .modal.popup-editor-dialog .promoted-attributes-widget {flex-shrink: 0;}-.modal.popup-editor-dialog .classic-toolbar-widget {+body.desktop .modal.popup-editor-dialog .classic-toolbar-widget {position: sticky;margin-inline: 8px;top: 0;@@ -155,6 +163,30 @@ body.mobile #root-widget:not(.virtual-keyboard-opened) .modal.popup-editor-dialoalign-items: flex-start;}+body.mobile .modal.popup-editor-dialog .modal-content:has(.classic-toolbar-outer-container.visible) .note-type-switcher {+ inset-block-end: calc(12px + 38px);+}++body.mobile .modal.popup-editor-dialog .modal-body {+ height: auto;+ flex: 1 1 auto;+ min-height: 0;+}++@media (max-width: 991px) {+ body.mobile .modal.popup-editor-dialog .classic-toolbar-outer-container.visible {+ height: calc(38px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));+ }++ body.mobile .modal.popup-editor-dialog .classic-toolbar-widget {+ bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));+ }++ body.mobile .modal.popup-editor-dialog .modal-content:has(.classic-toolbar-outer-container.visible) .note-type-switcher {+ inset-block-end: calc(12px + 38px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));+ }+}+.modal.popup-editor-dialog .note-detail {width: 100%;}diff --git a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsxindex 1cb1995c6a..b000ad8204 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx+++ b/apps/client/src/widgets/dialogs/PopupEditor.spec.tsx@@ -517,7 +517,15 @@ describe("PopupEditor", () => {);});- expect(mobileContainer.querySelector(".mobile-toolbar-stub")).not.toBeNull();+ // The fields and the note scroll above the toolbar, which stays at the foot of the dialog+ // as it does on a text note.+ const scroll = mobileContainer.querySelector(".popup-editor-scroll");+ const toolbar = mobileContainer.querySelector(".mobile-toolbar-stub");+ expect(scroll?.querySelector(".note-detail-stub")).not.toBeNull();+ expect(toolbar).not.toBeNull();+ expect(scroll?.contains(toolbar)).toBe(false);+ expect(scroll?.nextElementSibling).toBe(toolbar);+render(null, mobileContainer);mobileContainer.remove();});diff --git a/apps/client/src/widgets/dialogs/PopupEditor.tsx b/apps/client/src/widgets/dialogs/PopupEditor.tsxindex d3b95ad035..ad0f53e3b7 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.tsx+++ b/apps/client/src/widgets/dialogs/PopupEditor.tsx@@ -198,15 +198,16 @@ export default function PopupEditor({ ntxId = POPUP_EDITOR_NTX_ID, openCommand =noFocus // automatic focus breaks block popupstackable>- <PromotedAttributes />+ <div className="popup-editor-scroll">+ <PromotedAttributes />- {isMobile- ? <MobileEditorToolbar inPopupEditor />- : <FormattingToolbar />}+ {!isMobile && <FormattingToolbar />}- <NoteDetail />- <NoteList media="screen" displayOnlyCollections />+ <NoteDetail />+ <NoteList media="screen" displayOnlyCollections />+ </div>{switchable && <NoteTypeSwitcher note={noteContext.note} />}+ {isMobile && <MobileEditorToolbar />}</Modal></DialogWrapper></NoteContextContext.Provider>diff --git a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsxindex 0dbdbdfd82..21faa4dc29 100644--- a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx+++ b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx@@ -8,17 +8,13 @@ import { isIOS } from "../../../services/utils";import { useIsNoteReadOnly, useNoteContext, useNoteProperty, useTriliumEvent } from "../../react/hooks";import { useNestedEditor } from "./editable_embed";-interface MobileEditorToolbarProps {- inPopupEditor?: boolean;-}-/*** Handles the editing toolbar for CKEditor in mobile mode. The toolbar acts as a floating bar, with two different mechanism:** - On iOS, because it does not respect the viewport meta value `interactive-widget=resizes-content`, we need to listen to window resizes and scroll and reposition the toolbar using absolute positioning.* - On Android, the viewport change makes the keyboard resize the content area, all we have to do is to hide the tab bar and global menu (handled in the global style).*/-export default function MobileEditorToolbar({ inPopupEditor }: MobileEditorToolbarProps) {+export default function MobileEditorToolbar() {const containerRef = useRef<HTMLDivElement>(null);const { note, noteContext, ntxId } = useNoteContext();const noteType = useNoteProperty(note, "type");@@ -29,23 +25,21 @@ export default function MobileEditorToolbar({ inPopupEditor }: MobileEditorToolbconst nestedEditor = useNestedEditor(ntxId);const editor = nestedEditor?.ui.view.toolbar ? nestedEditor : noteEditor;- usePositioningOniOS(!inPopupEditor, containerRef);+ usePositioningOniOS(containerRef);// Attach the toolbar from the CKEditor.useTriliumEvent("textEditorRefreshed", ({ ntxId: eventNtxId, editor }) => {if (eventNtxId !== ntxId) return;- if (!inPopupEditor) {- repositionDropdowns(editor);- }+ repositionDropdowns(editor);setNoteEditor(editor);});useEffect(() => {- if (nestedEditor && !inPopupEditor) {+ if (nestedEditor) {repositionDropdowns(nestedEditor);}- }, [ nestedEditor, inPopupEditor ]);+ }, [ nestedEditor ]);useEffect(() => {const toolbar = editor?.ui.view.toolbar?.element;@@ -79,7 +73,7 @@ export default function MobileEditorToolbar({ inPopupEditor }: MobileEditorToolb);}-function usePositioningOniOS(enabled: boolean, wrapperRef: RefObject<HTMLDivElement | null>) {+function usePositioningOniOS(wrapperRef: RefObject<HTMLDivElement | null>) {// Fallback path for plain mobile Safari (no Capacitor): the WKWebView// isn't resized when the keyboard opens, so visualViewport.height// shrinks while window.innerHeight stays the same. Push the toolbar@@ -102,7 +96,7 @@ function usePositioningOniOS(enabled: boolean, wrapperRef: RefObject<HTMLDivElem}, [ wrapperRef ]);useEffect(() => {- if (!isIOS() || !enabled) return;+ if (!isIOS()) return;// Run once in case the keyboard is already up when mounting// (e.g. returning from a dialog).adjustPosition();@@ -110,7 +104,7 @@ function usePositioningOniOS(enabled: boolean, wrapperRef: RefObject<HTMLDivElemreturn () => {window.visualViewport?.removeEventListener("resize", adjustPosition);};- }, [ enabled, adjustPosition ]);+ }, [ adjustPosition ]);}/** The editors whose toolbar dropdowns open upwards already. */