This commit is contained in:
Vanessa 2022-11-02 18:46:34 +08:00
parent ba8d07b3d0
commit 5b669b6091
3 changed files with 18 additions and 2 deletions

View file

@ -8,6 +8,7 @@ import {escapeHtml} from "../util/escape";
import {unicode2Emoji} from "../emoji";
import {fetchPost} from "../util/fetch";
import {showTooltip} from "../dialog/tooltip";
import {isTouchDevice} from "../util/functions";
export class Tab {
public parent: Wnd;
@ -47,8 +48,8 @@ export class Tab {
let id = "";
if (this.model instanceof Editor && this.model.editor?.protyle?.block?.rootID) {
id = (this.model as Editor).editor.protyle.block.rootID;
} else if (!this.model){
const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}");
} else if (!this.model) {
const initData = JSON.parse(this.headElement.getAttribute("data-initdata") || "{}");
if (initData) {
id = initData.blockId;
}
@ -65,6 +66,11 @@ export class Tab {
}
});
this.headElement.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
if (isTouchDevice()) {
event.stopPropagation();
event.preventDefault();
return;
}
window.getSelection().removeAllRanges();
const tabElement = hasClosestByTag(event.target, "LI");
if (tabElement) {

View file

@ -16,6 +16,7 @@ import {confirmDialog} from "../../dialog/confirmDialog";
import {updateHotkeyTip} from "../../protyle/util/compatibility";
import {openFileById} from "../../editor/util";
import {hasClosestByTag, hasTopClosestByTag} from "../../protyle/util/hasClosest";
import {isTouchDevice} from "../../util/functions";
export class Files extends Model {
public element: HTMLElement;
@ -268,6 +269,11 @@ export class Files extends Model {
// b3-list-item--focus 样式会遮挡拖拽排序的上下线条
let focusElement: HTMLElement;
this.element.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
if (isTouchDevice()) {
event.stopPropagation();
event.preventDefault();
return;
}
window.getSelection().removeAllRanges();
focusElement = this.element.querySelector(".b3-list-item--focus");
if (focusElement) {

View file

@ -2,6 +2,10 @@ export const isMobile = () => {
return !document.getElementById("dockBottom");
};
export const isTouchDevice = () => {
return ("ontouchstart" in window) || navigator.maxTouchPoints > 0;
};
export const isArrayEqual = (arr1: string[], arr2: string[]) => {
return arr1.length === arr2.length && arr1.every((item) => arr2.includes(item));
};