diff --git a/app/src/layout/dock/Inbox.ts b/app/src/layout/dock/Inbox.ts index d2e990380..1f262965d 100644 --- a/app/src/layout/dock/Inbox.ts +++ b/app/src/layout/dock/Inbox.ts @@ -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,41 +222,36 @@ ${(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")) { + ids = this.selectIds; + } else { + ids = [detailsElement.getAttribute("data-id")]; + } + if (ids.length > 0) { + window.siyuan.menus.menu.append(new MenuItem({ + label: window.siyuan.languages.move, + icon: "iconMove", + click: () => { + this.move(ids); + } + }).element); + window.siyuan.menus.menu.append(new MenuItem({ + label: window.siyuan.languages.remove, + icon: "iconTrashcan", + click: () => { + confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.confirmDelete + "?", () => { if (detailsElement.classList.contains("fn__none")) { - this.move(item.id); + this.remove(); } else { - this.move(item.id, detailsElement.getAttribute("data-id")); + this.remove(detailsElement.getAttribute("data-id")); } - } - }); - } - }); - window.siyuan.menus.menu.append(new MenuItem({ - label: window.siyuan.languages.move, - icon: "iconMove", - submenu - }).element); - window.siyuan.menus.menu.append(new MenuItem({ - label: window.siyuan.languages.remove, - icon: "iconTrashcan", - click: () => { - confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.confirmDelete + "?", () => { - if (detailsElement.classList.contains("fn__none")) { - this.remove(); - } else { - this.remove(detailsElement.getAttribute("data-id")); - } - }); - } - }).element); - window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); + }); + } + }).element); + } + + window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16}); window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡 } @@ -289,22 +279,17 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)} }); } - private move(notebookId: string, id?: string) { - let ids: string[]; - if (id) { - ids = [id]; - } else { - ids = this.selectIds; - } - - ids.forEach(item => { - fetchPost("/api/filetree/createDoc", { - notebook: notebookId, - path: `/${Lute.NewNodeID()}.sy`, - title: replaceFileName(this.data[item].shorthandTitle), - md: this.data[item].shorthandContent, - }, () => { - this.remove(item); + private move(ids: string[]) { + movePathTo((toPath, toNotebook) => { + ids.forEach(item => { + fetchPost("/api/filetree/createDoc", { + 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); + }); }); }); }