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

@ -448,23 +448,3 @@
transition: var(--b3-transition); transition: var(--b3-transition);
} }
} }
// 触摸屏嵌入块固定显示操作按钮
@media (hover: none) {
.protyle-wysiwyg {
&[contenteditable="false"] .render-node[data-type=NodeBlockQueryEmbed] .protyle-action__edit {
display: none;
}
[data-node-id].render-node[data-type=NodeBlockQueryEmbed] {
.protyle-icons {
opacity: .86;
top: 8px;
& + .protyle-wysiwyg__embed > .protyle-breadcrumb__bar {
margin-right: 74px;
}
}
}
}
}

View file

@ -472,6 +472,10 @@
right: 4px; right: 4px;
top: 4px; top: 4px;
display: flex; display: flex;
&--show {
opacity: .86;
}
} }
&-icon { &-icon {

View file

@ -336,19 +336,6 @@ export class Background {
target = target.parentElement; target = target.parentElement;
} }
}); });
this.element.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;
}
this.element.classList.toggle("protyle-background--mobileshow");
});
} }
public render(ial: IObject, rootId: string) { public render(ial: IObject, rootId: string) {

View file

@ -3,6 +3,7 @@ import {lineNumberRender} from "../markdown/highlightRender";
import {scrollEvent} from "../scroll/event"; import {scrollEvent} from "../scroll/event";
import {isMobile} from "../../util/functions"; import {isMobile} from "../../util/functions";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
export const initUI = (protyle: IProtyle) => { export const initUI = (protyle: IProtyle) => {
protyle.contentElement = document.createElement("div"); protyle.contentElement = document.createElement("div");
@ -47,6 +48,28 @@ export const initUI = (protyle: IProtyle) => {
setEditMode(protyle, protyle.options.mode); setEditMode(protyle, protyle.options.mode);
document.execCommand("DefaultParagraphSeparator", false, "p"); 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) => { export const addLoading = (protyle: IProtyle) => {

View file

@ -305,7 +305,11 @@ export const disabledProtyle = (protyle: IProtyle) => {
} }
if (protyle.background) { if (protyle.background) {
protyle.background.element.classList.remove("protyle-background--enable"); protyle.background.element.classList.remove("protyle-background--enable");
protyle.background.element.classList.remove("protyle-background--mobileshow");
} }
protyle.wysiwyg.element.querySelectorAll(".protyle-icons--show").forEach(item => {
item.classList.remove("protyle-icons--show");
})
protyle.wysiwyg.element.style.userSelect = "text"; protyle.wysiwyg.element.style.userSelect = "text";
protyle.wysiwyg.element.setAttribute("contenteditable", "false"); protyle.wysiwyg.element.setAttribute("contenteditable", "false");
protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck="false"]').forEach(item => { protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck="false"]').forEach(item => {

View file

@ -1405,6 +1405,7 @@ export class WYSIWYG {
let shiftStartElement: HTMLElement; let shiftStartElement: HTMLElement;
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => { this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
hideElements(["hint", "util"], protyle); hideElements(["hint", "util"], protyle);
/// #if !MOBILE
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item"); const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
if (backlinkBreadcrumbItemElement) { if (backlinkBreadcrumbItemElement) {
const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id") const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id")
@ -1421,6 +1422,7 @@ export class WYSIWYG {
event.stopPropagation(); event.stopPropagation();
return; return;
} }
/// #endif
if (!window.siyuan.shiftIsPressed) { if (!window.siyuan.shiftIsPressed) {
shiftStartElement = undefined; shiftStartElement = undefined;
} }

View file

@ -7,6 +7,7 @@ import {ipcRenderer, OpenDialogReturnValue} from "electron";
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import {afterExport} from "../protyle/export/util"; import {afterExport} from "../protyle/export/util";
import {destroyPrintWindow} from "../protyle/export";
/// #endif /// #endif
import {Constants} from "../constants"; import {Constants} from "../constants";
import {appearance} from "../config/appearance"; import {appearance} from "../config/appearance";
@ -29,7 +30,6 @@ import {showMessage} from "../dialog/message";
import {replaceLocalPath} from "../editor/rename"; import {replaceLocalPath} from "../editor/rename";
import {editor} from "../config/editor"; import {editor} from "../config/editor";
import {goBack, goForward} from "./backForward"; import {goBack, goForward} from "./backForward";
import {destroyPrintWindow} from "../protyle/export";
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => { const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
if (key1 === "general") { if (key1 === "general") {