Skip to content

Commit

Permalink
feat(mobile): display classic toolbar above keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Dec 28, 2024
1 parent b168d68 commit 62696a4
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/public/app/widgets/ribbon_widgets/classic_editor_toolbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { t } from "../../services/i18n.js";
import options from "../../services/options.js";
import utils from "../../services/utils.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";

const TPL = `\
Expand All @@ -8,7 +9,7 @@ const TPL = `\
<style>
.classic-toolbar-widget {
--ck-color-toolbar-background: transparent;
--ck-color-button-default-background: transparent;
--ck-color-button-default-background: transparent;
--ck-color-button-default-disabled-background: transparent;
min-height: 39px;
}
Expand All @@ -22,8 +23,12 @@ const TPL = `\
}
body.mobile .classic-toolbar-widget {
position: relative;
position: fixed;
left: 0;
bottom: var(--launcher-pane-size);
right: 0;
overflow-x: auto;
background: var(--main-background-color);
}
body.mobile .classic-toolbar-widget .ck.ck-toolbar {
Expand All @@ -34,10 +39,10 @@ const TPL = `\

/**
* Handles the editing toolbar when the CKEditor is in decoupled mode.
*
*
* <p>
* This toolbar is only enabled if the user has selected the classic CKEditor.
*
*
* <p>
* The ribbon item is active by default for text notes, as long as they are not in read-only mode.
*/
Expand All @@ -53,6 +58,22 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
doRender() {
this.$widget = $(TPL);
this.contentSized();

if (utils.isMobile()) {
let originalHeight = window.visualViewport.height;
let originalBottom = this.$widget[0].style.bottom;
window.visualViewport.addEventListener("resize", () => {
const keyboardSize = originalHeight - window.visualViewport.height;
const bottom = Math.max(keyboardSize, originalBottom);

if (keyboardSize !== 0) {
this.$widget.css("bottom", `${bottom}px`);``
} else {
const style = window.getComputedStyle(this.$widget[0]);
this.$widget.css("bottom", style.getPropertyValue("--launcher-pane-size"));
}
});
}
}

async getTitle() {
Expand Down Expand Up @@ -80,4 +101,4 @@ export default class ClassicEditorToolbar extends NoteContextAwareWidget {
return true;
}

}
}

0 comments on commit 62696a4

Please sign in to comment.