This commit is contained in:
Vanessa 2022-10-28 12:27:44 +08:00
parent d7321cccec
commit 8b3e3d2c9a
7 changed files with 34 additions and 34 deletions

View file

@ -3,6 +3,7 @@ import {lineNumberRender} from "../markdown/highlightRender";
import {scrollEvent} from "../scroll/event";
import {isMobile} from "../../util/functions";
import {Constants} from "../../constants";
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
export const initUI = (protyle: IProtyle) => {
protyle.contentElement = document.createElement("div");
@ -47,6 +48,28 @@ export const initUI = (protyle: IProtyle) => {
setEditMode(protyle, protyle.options.mode);
document.execCommand("DefaultParagraphSeparator", false, "p");
// 触摸屏背景和嵌入块按钮显示
protyle.contentElement.addEventListener("touchstart", (event) => {
// https://github.com/siyuan-note/siyuan/issues/6328
if (protyle.disabled) {
return;
}
const target = event.target as HTMLElement;
if (hasClosestByClassName(target, "protyle-icons") ||
hasClosestByClassName(target, "item") ||
target.classList.contains("protyle-background__icon")) {
return;
}
if (hasClosestByClassName(target, "protyle-background")) {
protyle.background.element.classList.toggle("protyle-background--mobileshow");
return;
}
const embedBlockElement = hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed")
if (embedBlockElement) {
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
}
});
};
export const addLoading = (protyle: IProtyle) => {