Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile/text): float the formatting toolbar over the note

Elian Doran35cf20ff5075
diff --git a/apps/client/src/widgets/dialogs/PopupEditor.css b/apps/client/src/widgets/dialogs/PopupEditor.css
index 08ff03d2c0..3653bc9d74 100644
--- a/apps/client/src/widgets/dialogs/PopupEditor.css
+++ b/apps/client/src/widgets/dialogs/PopupEditor.css
@@ -144,6 +144,7 @@ body.mobile .modal.popup-editor-dialog .popup-editor-scroll {
}
.modal.popup-editor-dialog .classic-toolbar-outer-container.visible {
+ --mobile-toolbar-backdrop: var(--modal-background-color);
background-color: transparent;
}
@@ -177,8 +178,8 @@ 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(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 {
+ --mobile-toolbar-clearance: 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-island {
diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsx
index 40c10fee55..0d89708b03 100644
--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx
+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx
@@ -538,7 +538,9 @@ export default function EditableText({
const visibleBottom = Math.min(containerRect.bottom, viewportBottom);
const visibleTop = Math.max(containerRect.top, viewportTop);
- const overshoot = caretRect.bottom - (visibleBottom - CARET_BOTTOM_MARGIN_PX);
+ // The mobile formatting toolbar floats over the scroller and reserves its height here.
+ const toolbarClearance = parseFloat(getComputedStyle(scroller).scrollPaddingBottom) || 0;
+ const overshoot = caretRect.bottom - (visibleBottom - toolbarClearance - CARET_BOTTOM_MARGIN_PX);
if (overshoot > 0) {
scroller.scrollTop += overshoot;
return;
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.css
index 67c14bd07e..9e7f81eb89 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
@@ -2,16 +2,24 @@ body.mobile {
/* Read by `PopupEditor.css` to clear the toolbar. */
--mobile-toolbar-height: 40px;
--mobile-toolbar-gap: 6px;
+ --mobile-toolbar-clearance: calc(var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap));
.classic-toolbar-outer-container {
contain: none !important;
}
.classic-toolbar-outer-container.visible {
- height: calc(var(--mobile-toolbar-height) + 2 * var(--mobile-toolbar-gap));
+ height: 0;
position: relative;
overflow: visible;
flex-shrink: 0;
+ z-index: var(--ck-z-panel);
+ }
+
+ /* The `scroll-padding-bottom` is read by `EditableText` to keep the caret above the toolbar. */
+ :is(.scrolling-container, .popup-editor-scroll):has(~ .classic-toolbar-outer-container.visible) {
+ padding-bottom: var(--mobile-toolbar-clearance);
+ scroll-padding-bottom: var(--mobile-toolbar-clearance);
}
.classic-toolbar-island {
@@ -23,7 +31,13 @@ body.mobile {
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));
+ /* `--card-background-color` is translucent in theme-next, so it tints an opaque backdrop. */
+ background:
+ linear-gradient(
+ var(--card-background-color, var(--accented-background-color)),
+ var(--card-background-color, var(--accented-background-color))
+ ),
+ var(--mobile-toolbar-backdrop, var(--main-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