mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 08:16:10 +01:00
This commit is contained in:
parent
5cd2c14009
commit
3a918e70ba
3 changed files with 24 additions and 4 deletions
|
|
@ -15,7 +15,7 @@ import {promiseTransactions} from "../protyle/wysiwyg/transaction";
|
|||
import {bootSync} from "../dialog/processSystem";
|
||||
import {initMessage} from "../dialog/message";
|
||||
import {goBack} from "./util/MobileBackFoward";
|
||||
import {hideKeyboardToolbar} from "./util/keyboardToolbar";
|
||||
import {hideKeyboardToolbar, renderKeyboardToolbar} from "./util/keyboardToolbar";
|
||||
import {getLocalStorage} from "../protyle/util/compatibility";
|
||||
import {openMobileFileById} from "./editor";
|
||||
import {getSearch} from "../util/functions";
|
||||
|
|
@ -86,6 +86,7 @@ new App();
|
|||
window.goBack = goBack;
|
||||
window.showKeyboardToolbar = (height) => {
|
||||
document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString());
|
||||
renderKeyboardToolbar();
|
||||
};
|
||||
window.hideKeyboardToolbar = hideKeyboardToolbar;
|
||||
window.openFileByURL = (openURL) => {
|
||||
|
|
|
|||
|
|
@ -170,15 +170,18 @@ const hideKeyboardToolbarUtil = () => {
|
|||
toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconKeyboardHide");
|
||||
};
|
||||
|
||||
const renderKeyboardToolbar = () => {
|
||||
export const renderKeyboardToolbar = () => {
|
||||
clearTimeout(renderKeyboardToolbarTimeout);
|
||||
renderKeyboardToolbarTimeout = window.setTimeout(() => {
|
||||
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly ||
|
||||
if (getSelection().rangeCount === 0 ||
|
||||
window.siyuan.config.editor.readOnly ||
|
||||
window.siyuan.config.readonly ||
|
||||
!document.activeElement || (
|
||||
document.activeElement &&
|
||||
document.activeElement.tagName !== "INPUT" &&
|
||||
document.activeElement.tagName !== "TEXTAREA" &&
|
||||
!document.activeElement.classList.contains("protyle-wysiwyg")
|
||||
!document.activeElement.classList.contains("protyle-wysiwyg") &&
|
||||
document.activeElement.getAttribute("contenteditable") !== "true"
|
||||
)) {
|
||||
hideKeyboardToolbar();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1185,7 +1185,11 @@ export class WYSIWYG {
|
|||
focusSideBlock(embedElement);
|
||||
}
|
||||
protyle.gutter.renderMenu(protyle, embedElement);
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup({x, y});
|
||||
/// #endif
|
||||
return false;
|
||||
}
|
||||
protyle.toolbar.range = getEditorRange(protyle.element);
|
||||
|
|
@ -1252,7 +1256,11 @@ export class WYSIWYG {
|
|||
if (protyle.gutter) {
|
||||
protyle.gutter.renderMenu(protyle, nodeElement);
|
||||
}
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup({x, y});
|
||||
/// #endif
|
||||
protyle.toolbar?.element.classList.add("fn__none");
|
||||
}
|
||||
});
|
||||
|
|
@ -1747,11 +1755,15 @@ export class WYSIWYG {
|
|||
const menuElement = hasClosestByClassName(event.target, "protyle-action__menu");
|
||||
if (menuElement) {
|
||||
protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement);
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
const rect = menuElement.getBoundingClientRect();
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
}, true);
|
||||
/// #endif
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
|
@ -1840,10 +1852,14 @@ export class WYSIWYG {
|
|||
updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html);
|
||||
} else {
|
||||
protyle.gutter.renderMenu(protyle, actionElement.parentElement);
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: event.clientX - 16,
|
||||
y: event.clientY - 16
|
||||
}, true);
|
||||
/// #endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue