mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
This commit is contained in:
parent
4e3fb4bbf5
commit
0d9fcf8245
1 changed files with 42 additions and 57 deletions
|
|
@ -9,9 +9,7 @@ import {needSubscribe} from "../../util/needSubscribe";
|
|||
import {MenuItem} from "../../menus/Menu";
|
||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||
import {replaceFileName} from "../../editor/rename";
|
||||
import {escapeHtml} from "../../util/escape";
|
||||
import {unicode2Emoji} from "../../emoji";
|
||||
import {Constants} from "../../constants";
|
||||
import {getDisplayName, movePathTo, pathPosix} from "../../util/pathName";
|
||||
|
||||
export class Inbox extends Model {
|
||||
private element: Element;
|
||||
|
|
@ -89,7 +87,6 @@ export class Inbox extends Model {
|
|||
const type = target.getAttribute("data-type");
|
||||
if (type === "min") {
|
||||
getDockByType("inbox").toggleModel("inbox");
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "selectall") {
|
||||
|
|
@ -106,6 +103,7 @@ export class Inbox extends Model {
|
|||
});
|
||||
}
|
||||
countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`;
|
||||
window.siyuan.menus.menu.remove();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "select") {
|
||||
|
|
@ -117,6 +115,7 @@ export class Inbox extends Model {
|
|||
}
|
||||
countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`;
|
||||
selectAllElement.checked = this.element.lastElementChild.querySelectorAll("input:checked").length === this.element.lastElementChild.querySelectorAll(".b3-list-item").length;
|
||||
window.siyuan.menus.menu.remove();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "previous") {
|
||||
|
|
@ -124,7 +123,6 @@ export class Inbox extends Model {
|
|||
this.currentPage--;
|
||||
this.update();
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "next") {
|
||||
|
|
@ -132,12 +130,10 @@ export class Inbox extends Model {
|
|||
this.currentPage++;
|
||||
this.update();
|
||||
}
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "back") {
|
||||
this.back();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "more") {
|
||||
|
|
@ -155,7 +151,6 @@ export class Inbox extends Model {
|
|||
detailsElement.classList.remove("fn__none");
|
||||
detailsElement.scrollTop = 0;
|
||||
this.element.lastElementChild.classList.add("fn__none");
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
|
|
@ -173,7 +168,7 @@ export class Inbox extends Model {
|
|||
this.element.lastElementChild.classList.remove("fn__none");
|
||||
}
|
||||
|
||||
private genDetail(data:IInbox) {
|
||||
private genDetail(data: IInbox) {
|
||||
let linkHTML = "";
|
||||
/// #if MOBILE
|
||||
if (data.shorthandURL) {
|
||||
|
|
@ -227,26 +222,19 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
|
|||
}
|
||||
}
|
||||
}).element);
|
||||
const submenu: IMenu[] = [];
|
||||
window.siyuan.notebooks.forEach((item) => {
|
||||
if (!item.closed) {
|
||||
submenu.push({
|
||||
iconHTML: `${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, false, "b3-menu__icon", true)}`,
|
||||
label: escapeHtml(item.name),
|
||||
click: () => {
|
||||
let ids: string[] = [];
|
||||
if (detailsElement.classList.contains("fn__none")) {
|
||||
this.move(item.id);
|
||||
ids = this.selectIds;
|
||||
} else {
|
||||
this.move(item.id, detailsElement.getAttribute("data-id"));
|
||||
ids = [detailsElement.getAttribute("data-id")];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (ids.length > 0) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.move,
|
||||
icon: "iconMove",
|
||||
submenu
|
||||
click: () => {
|
||||
this.move(ids);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.remove,
|
||||
|
|
@ -261,7 +249,9 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
|
|||
});
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
|
||||
}
|
||||
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16});
|
||||
window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡
|
||||
}
|
||||
|
||||
|
|
@ -289,24 +279,19 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
|
|||
});
|
||||
}
|
||||
|
||||
private move(notebookId: string, id?: string) {
|
||||
let ids: string[];
|
||||
if (id) {
|
||||
ids = [id];
|
||||
} else {
|
||||
ids = this.selectIds;
|
||||
}
|
||||
|
||||
private move(ids: string[]) {
|
||||
movePathTo((toPath, toNotebook) => {
|
||||
ids.forEach(item => {
|
||||
fetchPost("/api/filetree/createDoc", {
|
||||
notebook: notebookId,
|
||||
path: `/${Lute.NewNodeID()}.sy`,
|
||||
notebook: toNotebook[0],
|
||||
path: pathPosix().join(getDisplayName(toPath[0], false, true), Lute.NewNodeID() + ".sy"),
|
||||
title: replaceFileName(this.data[item].shorthandTitle),
|
||||
md: this.data[item].shorthandContent,
|
||||
}, () => {
|
||||
this.remove(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private update() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue