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
feat(mobile): float the formatting toolbar as an island
Elian Doranf8cb1326f662
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.css b/apps/client/src/widgets/dialogs/PopupEditor.cssindex f70e67f5f0..08ff03d2c0 100644--- a/apps/client/src/widgets/dialogs/PopupEditor.css+++ b/apps/client/src/widgets/dialogs/PopupEditor.css@@ -167,7 +167,7 @@ body.desktop .modal.popup-editor-dialog .classic-toolbar-widget {}body.mobile .modal.popup-editor-dialog .modal-content:has(.classic-toolbar-outer-container.visible) .note-type-switcher {- inset-block-end: calc(12px + 38px);+ inset-block-end: calc(12px + var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap));}body.mobile .modal.popup-editor-dialog .modal-body {@@ -178,15 +178,15 @@ body.mobile .modal.popup-editor-dialog .modal-body {@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)));+ height: calc(var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));}- body.mobile .modal.popup-editor-dialog .classic-toolbar-widget {+ body.mobile .modal.popup-editor-dialog .classic-toolbar-island {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)));+ inset-block-end: calc(12px + var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));}}diff --git a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.cssindex c062092ae2..2e3968aa0a 100644--- a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css+++ b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css@@ -28,6 +28,6 @@ body.mobile .hide-keyboard-button {}}-body.mobile:has(.hide-keyboard-button .icon-action) .classic-toolbar-widget {- padding-inline-end: var(--hide-keyboard-button-size);+body.mobile:has(.hide-keyboard-button .icon-action) .classic-toolbar-island {+ margin-inline-end: calc(var(--hide-keyboard-button-size) + var(--mobile-toolbar-gap));}diff --git a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.css b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.cssindex c187e752d4..0463783ae9 100644--- a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.css+++ b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.css@@ -1,32 +1,49 @@body.mobile {+ /* Read by `PopupEditor.css` to clear the toolbar. */+ --mobile-toolbar-height: 40px;+ --mobile-toolbar-gap: 6px;+.classic-toolbar-outer-container {contain: none !important;}.classic-toolbar-outer-container.visible {- height: 38px;+ height: calc(var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap));position: relative;overflow: visible;flex-shrink: 0;}+ .classic-toolbar-island {+ position: absolute;+ bottom: 0;+ inset-inline-start: 0;+ inset-inline-end: 0;+ height: var(--mobile-toolbar-height);+ margin: 0 var(--mobile-toolbar-gap) var(--mobile-toolbar-gap);+ border: 1px solid var(--card-border-color, var(--main-border-color));+ border-radius: 6px;+ background: var(--card-background-color, var(--accented-background-color));+ /* On iOS, `--tn-keyboard-gap` is updated continuously by the+ ViewController (Swift) as the keyboard frame changes, so the+ toolbar follows a finger-dragged keyboard during interactive+ dismiss. Zero elsewhere — no effect on Android or non-Capacitor. */+ transform: translateY(var(--tn-keyboard-gap, 0px));+ }+.classic-toolbar-widget {position: absolute;bottom: 0;inset-inline-start: 0;inset-inline-end: 0;- height: 38px;+ height: 100%;+ border-radius: 5px;overflow: scroll;display: flex;align-items: flex-end;user-select: none;touch-action: pan-x;scrollbar-width: 0 !important;- /* On iOS, `--tn-keyboard-gap` is updated continuously by the- ViewController (Swift) as the keyboard frame changes, so the- toolbar follows a finger-dragged keyboard during interactive- dismiss. Zero elsewhere — no effect on Android or non-Capacitor. */- transform: translateY(var(--tn-keyboard-gap, 0px));}.classic-toolbar-widget::-webkit-scrollbar:horizontal {@@ -35,10 +52,12 @@ body.mobile {.classic-toolbar-widget.dropdown-active {height: 50vh;+ border-start-start-radius: 0;+ border-start-end-radius: 0;}.classic-toolbar-widget .ck.ck-toolbar {- --ck-color-toolbar-background: var(--main-background-color);+ --ck-color-toolbar-background: transparent;--ck-color-button-default-background: transparent;--ck-color-button-default-disabled-background: transparent;position: absolute;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 21faa4dc29..79c3cf19e5 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@@ -15,6 +15,7 @@ import { useNestedEditor } from "./editable_embed";* - 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() {+ const islandRef = useRef<HTMLDivElement>(null);const containerRef = useRef<HTMLDivElement>(null);const { note, noteContext, ntxId } = useNoteContext();const noteType = useNoteProperty(note, "type");@@ -25,7 +26,7 @@ export default function MobileEditorToolbar() {const nestedEditor = useNestedEditor(ntxId);const editor = nestedEditor?.ui.view.toolbar ? nestedEditor : noteEditor;- usePositioningOniOS(containerRef);+ usePositioningOniOS(islandRef);// Attach the toolbar from the CKEditor.useTriliumEvent("textEditorRefreshed", ({ ntxId: eventNtxId, editor }) => {@@ -68,7 +69,9 @@ export default function MobileEditorToolbar() {return (<div className={`classic-toolbar-outer-container ${!shouldDisplay ? "hidden-ext" : "visible"} ${isIOS() ? "ios" : ""}`}>- <div ref={containerRef} className={`classic-toolbar-widget ${dropdownActive ? "dropdown-active" : ""}`} />+ <div ref={islandRef} className="classic-toolbar-island">+ <div ref={containerRef} className={`classic-toolbar-widget ${dropdownActive ? "dropdown-active" : ""}`} />+ </div></div>);}