mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
8224303021
commit
532cb82f4f
6 changed files with 47 additions and 21 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
background-color: var(--b3-theme-background);
|
background-color: var(--b3-theme-background);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
padding: 16px;
|
||||||
|
|
||||||
& > div {
|
& > div {
|
||||||
font-size: 64px;
|
font-size: 64px;
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,12 @@ export const openCardByData = (cardsData: { cards: ICard[], unreviewedCount: num
|
||||||
</div>`,
|
</div>`,
|
||||||
width: isMobile() ? "100vw" : "80vw",
|
width: isMobile() ? "100vw" : "80vw",
|
||||||
height: isMobile() ? "100vh" : "70vh",
|
height: isMobile() ? "100vh" : "70vh",
|
||||||
|
destroyCallback() {
|
||||||
|
if (editor) {
|
||||||
|
editor.destroy();
|
||||||
|
window.siyuan.mobile.popEditor = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
(dialog.element.querySelector(".b3-dialog__scrim") as HTMLElement).style.backgroundColor = "var(--b3-theme-background)";
|
(dialog.element.querySelector(".b3-dialog__scrim") as HTMLElement).style.backgroundColor = "var(--b3-theme-background)";
|
||||||
(dialog.element.querySelector(".b3-dialog__container") as HTMLElement).style.maxWidth = "1024px";
|
(dialog.element.querySelector(".b3-dialog__container") as HTMLElement).style.maxWidth = "1024px";
|
||||||
|
|
@ -118,6 +124,7 @@ export const openCardByData = (cardsData: { cards: ICard[], unreviewedCount: num
|
||||||
},
|
},
|
||||||
typewriterMode: false
|
typewriterMode: false
|
||||||
});
|
});
|
||||||
|
window.siyuan.mobile.popEditor = editor;
|
||||||
if (window.siyuan.config.editor.readOnly) {
|
if (window.siyuan.config.editor.readOnly) {
|
||||||
disabledProtyle(editor.protyle);
|
disabledProtyle(editor.protyle);
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +144,7 @@ export const openCardByData = (cardsData: { cards: ICard[], unreviewedCount: num
|
||||||
const selectElement = dialog.element.querySelector("select");
|
const selectElement = dialog.element.querySelector("select");
|
||||||
dialog.element.addEventListener("click", (event) => {
|
dialog.element.addEventListener("click", (event) => {
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
const titleElement = countElement.previousElementSibling;
|
const titleElement = countElement?.previousElementSibling;
|
||||||
let type = "";
|
let type = "";
|
||||||
if (typeof event.detail === "string") {
|
if (typeof event.detail === "string") {
|
||||||
if (event.detail === "1" || event.detail === "j") {
|
if (event.detail === "1" || event.detail === "j") {
|
||||||
|
|
@ -294,7 +301,7 @@ export const openCardByData = (cardsData: { cards: ICard[], unreviewedCount: num
|
||||||
}
|
}
|
||||||
selectElement.addEventListener("change", () => {
|
selectElement.addEventListener("change", () => {
|
||||||
fetchPost("/api/riff/getRiffDueCards", {deckID: selectElement.value}, (cardsChangeResponse) => {
|
fetchPost("/api/riff/getRiffDueCards", {deckID: selectElement.value}, (cardsChangeResponse) => {
|
||||||
blocks = cardsChangeResponse.data.blocks;
|
blocks = cardsChangeResponse.data.cards;
|
||||||
index = 0;
|
index = 0;
|
||||||
if (blocks.length > 0) {
|
if (blocks.length > 0) {
|
||||||
nextCard({
|
nextCard({
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,12 @@ export const viewCards = (deckID: string, title: string, deckType: "Tree" | "" |
|
||||||
<div class="fn__flex-1 card__empty">${window.siyuan.languages.emptyContent}</div>
|
<div class="fn__flex-1 card__empty">${window.siyuan.languages.emptyContent}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`,
|
||||||
width: isMobile() ? "98vw" : "80vw",
|
width: isMobile() ? "100vw" : "80vw",
|
||||||
height: isMobile() ? "80vh" : "70vh",
|
height: isMobile() ? "100vh" : "70vh",
|
||||||
destroyCallback() {
|
destroyCallback() {
|
||||||
if (edit) {
|
if (edit) {
|
||||||
edit.destroy();
|
edit.destroy();
|
||||||
|
window.siyuan.mobile.popEditor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -57,6 +58,7 @@ export const viewCards = (deckID: string, title: string, deckType: "Tree" | "" |
|
||||||
breadcrumbDocName: true
|
breadcrumbDocName: true
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
window.siyuan.mobile.popEditor = edit;
|
||||||
if (window.siyuan.config.editor.readOnly) {
|
if (window.siyuan.config.editor.readOnly) {
|
||||||
disabledProtyle(edit.protyle);
|
disabledProtyle(edit.protyle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import {setStorageVal} from "../protyle/util/compatibility";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
|
|
||||||
|
export const getCurrentEditor = () => {
|
||||||
|
return window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
|
||||||
|
}
|
||||||
|
|
||||||
export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) => {
|
export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) => {
|
||||||
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action};
|
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action};
|
||||||
setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);
|
setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {hasClosestBlock, hasClosestByClassName, hasClosestByMatchTag} from "../.
|
||||||
import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";
|
import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
|
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
|
||||||
|
import {getCurrentEditor} from "../editor";
|
||||||
|
|
||||||
let renderKeyboardToolbarTimeout: number;
|
let renderKeyboardToolbarTimeout: number;
|
||||||
let showUtil = false;
|
let showUtil = false;
|
||||||
|
|
@ -152,8 +153,11 @@ const showKeyboardToolbarUtil = (oldScrollTop: number) => {
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight");
|
let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight");
|
||||||
keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px";
|
keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px";
|
||||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = keyboardHeight;
|
const editor = getCurrentEditor();
|
||||||
window.siyuan.mobile.editor.protyle.contentElement.scrollTop = oldScrollTop;
|
if (editor) {
|
||||||
|
editor.protyle.element.parentElement.style.paddingBottom = keyboardHeight;
|
||||||
|
editor.protyle.contentElement.scrollTop = oldScrollTop;
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toolbarElement.style.height = keyboardHeight;
|
toolbarElement.style.height = keyboardHeight;
|
||||||
}, Constants.TIMEOUT_TRANSITION); // 防止抖动
|
}, Constants.TIMEOUT_TRANSITION); // 防止抖动
|
||||||
|
|
@ -165,7 +169,10 @@ const showKeyboardToolbarUtil = (oldScrollTop: number) => {
|
||||||
const hideKeyboardToolbarUtil = () => {
|
const hideKeyboardToolbarUtil = () => {
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
toolbarElement.style.height = "";
|
toolbarElement.style.height = "";
|
||||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "42px";
|
const editor = getCurrentEditor();
|
||||||
|
if (editor) {
|
||||||
|
editor.protyle.element.parentElement.style.paddingBottom = "42px";
|
||||||
|
}
|
||||||
toolbarElement.querySelector('.keyboard__action[data-type="add"]').classList.remove("protyle-toolbar__item--current");
|
toolbarElement.querySelector('.keyboard__action[data-type="add"]').classList.remove("protyle-toolbar__item--current");
|
||||||
toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconKeyboardHide");
|
toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconKeyboardHide");
|
||||||
};
|
};
|
||||||
|
|
@ -268,22 +275,23 @@ export const showKeyboardToolbar = () => {
|
||||||
modelElement.style.paddingBottom = "42px";
|
modelElement.style.paddingBottom = "42px";
|
||||||
}
|
}
|
||||||
const range = getSelection().getRangeAt(0);
|
const range = getSelection().getRangeAt(0);
|
||||||
if (!window.siyuan.mobile.editor ||
|
const editor = getCurrentEditor();
|
||||||
!window.siyuan.mobile.editor.protyle.wysiwyg.element.contains(range.startContainer)) {
|
if (editor && editor.protyle.wysiwyg.element.contains(range.startContainer)) {
|
||||||
return;
|
editor.protyle.element.parentElement.style.paddingBottom = "42px";
|
||||||
}
|
}
|
||||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "42px";
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const contentElement = window.siyuan.mobile.editor.protyle.contentElement;
|
const contentElement = hasClosestByClassName(range.startContainer, "protyle-content", true);
|
||||||
const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;
|
if (contentElement) {
|
||||||
if (cursorTop < window.innerHeight - 96) {
|
const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;
|
||||||
return;
|
if (cursorTop < window.innerHeight - 96) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
contentElement.scroll({
|
||||||
|
top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 65) / 2 - 30),
|
||||||
|
left: contentElement.scrollLeft,
|
||||||
|
behavior: "smooth"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
contentElement.scroll({
|
|
||||||
top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 65) / 2 - 30),
|
|
||||||
left: contentElement.scrollLeft,
|
|
||||||
behavior: "smooth"
|
|
||||||
});
|
|
||||||
}, Constants.TIMEOUT_TRANSITION);
|
}, Constants.TIMEOUT_TRANSITION);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -294,7 +302,10 @@ export const hideKeyboardToolbar = () => {
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
toolbarElement.classList.add("fn__none");
|
toolbarElement.classList.add("fn__none");
|
||||||
toolbarElement.style.height = "";
|
toolbarElement.style.height = "";
|
||||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = "";
|
const editor = getCurrentEditor();
|
||||||
|
if (editor) {
|
||||||
|
editor.protyle.element.parentElement.style.paddingBottom = "";
|
||||||
|
}
|
||||||
const modelElement = document.getElementById("model");
|
const modelElement = document.getElementById("model");
|
||||||
if (modelElement.style.transform === "translateY(0px)") {
|
if (modelElement.style.transform === "translateY(0px)") {
|
||||||
modelElement.style.paddingBottom = "";
|
modelElement.style.paddingBottom = "";
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -198,6 +198,7 @@ interface ISiyuan {
|
||||||
backStack?: IBackStack[],
|
backStack?: IBackStack[],
|
||||||
mobile?: {
|
mobile?: {
|
||||||
editor?: import("../protyle").Protyle
|
editor?: import("../protyle").Protyle
|
||||||
|
popEditor?: import("../protyle").Protyle
|
||||||
files?: import("../mobile/util/MobileFiles").MobileFiles
|
files?: import("../mobile/util/MobileFiles").MobileFiles
|
||||||
},
|
},
|
||||||
user?: {
|
user?: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue