Skip to content

Commit 6d7ac9e

Browse files
author
prima
committed
fix: Editor on mobile... maybe
1 parent 1a1055e commit 6d7ac9e

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

klite.embd

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41410,7 +41410,50 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
4141041410
let editorContentArea = document.querySelector(".md-editor-content-area")
4141141411
editorContentArea.prepend(rawTextEditor)
4141241412

41413+
let fixMobileSizing = () => {
41414+
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
41415+
41416+
let portrait = true
41417+
switch (screen?.orientation?.type) {
41418+
case "landscape-primary":
41419+
case "landscape-secondary":
41420+
portrait = false
41421+
break;
41422+
}
41423+
41424+
let activeTab = document.querySelector(".md-tab-button.active")
41425+
if (!!activeTab)
41426+
{
41427+
let contentArea = document.getElementsByClassName("md-editor-content-area")[0];
41428+
if (isMobile)
41429+
{
41430+
if (activeTab.innerText === "Raw text") {
41431+
contentArea.style.maxHeight = "calc(100% - 40px)"
41432+
}
41433+
else if (activeTab.innerText === "WYSIWYG") {
41434+
if (portrait)
41435+
{
41436+
contentArea.style.maxHeight = "calc(100% - 130px)"
41437+
}
41438+
else
41439+
{
41440+
contentArea.style.maxHeight = "calc(100% - 90px)"
41441+
}
41442+
}
41443+
else if (activeTab.innerText === "Markdown") {
41444+
contentArea.style.maxHeight = "calc(100% - 90px)"
41445+
}
41446+
}
41447+
else
41448+
{
41449+
contentArea.style.maxHeight = ""
41450+
}
41451+
}
41452+
}
41453+
4141341454
let scrollToBottom = () => {
41455+
fixMobileSizing()
41456+
4141441457
setTimeout(() => {
4141541458
// Scroll to latest message
4141641459
[...document.querySelectorAll("#rawTextEditor, .md-editable-area, .md-markdown-area")].forEach(elem => elem.scrollTo(0, elem.scrollHeight));
@@ -41425,7 +41468,7 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
4142541468

4142641469
elem.target.classList.add("active")
4142741470

41428-
let toolbarElem = document.getElementsByClassName("md-toolbar")[0]
41471+
let toolbarElem = document.getElementsByClassName("md-toolbar")[0];
4142941472
if (elem.target.innerText === "Raw text") {
4143041473
rawTextEditor.style.display = "block"
4143141474
toolbarElem.style.display = "none"
@@ -41438,6 +41481,7 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
4143841481
document.querySelectorAll(".md-markdown-area").forEach(elem => elem.style.display = "block")
4143941482
toolbarElem.style.display = "flex"
4144041483
}
41484+
4144141485
scrollToBottom()
4144241486
}))
4144341487
rawButton.dispatchEvent(new CustomEvent("mouseup", { target: rawButton }))

0 commit comments

Comments
 (0)