diff --git a/app/src/layout/dock/Bookmark.ts b/app/src/layout/dock/Bookmark.ts index da372ab32..21771cb4c 100644 --- a/app/src/layout/dock/Bookmark.ts +++ b/app/src/layout/dock/Bookmark.ts @@ -77,7 +77,7 @@ export class Bookmark extends Model { element: this.element.lastElementChild as HTMLElement, data: null, click(element: HTMLElement) { - const id = element.getAttribute("data-node-id"); + const id = element.getAttribute("data-node-id"); fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, @@ -88,7 +88,8 @@ export class Bookmark extends Model { }, rightClick: (element: HTMLElement, event: MouseEvent) => { window.siyuan.menus.menu.remove(); - if (!element.getAttribute("data-node-id")) { + const id = element.getAttribute("data-node-id") + if (!id) { window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.rename, click: () => { @@ -123,13 +124,14 @@ export class Bookmark extends Model { }); } }).element); - } else { - window.siyuan.menus.menu.append(new MenuItem({ - icon: "iconTrashcan", - label: window.siyuan.languages.remove, - click: () => { - confirmDialog(window.siyuan.languages.delete, `${window.siyuan.languages.confirmDelete} ${escapeHtml(element.parentElement.previousElementSibling.querySelector(".b3-list-item__text").textContent)}?`, () => { - const id = element.getAttribute("data-node-id"); + } + window.siyuan.menus.menu.append(new MenuItem({ + icon: "iconTrashcan", + label: window.siyuan.languages.remove, + click: () => { + const bookmark = (id ? element.parentElement.previousElementSibling : element).querySelector(".b3-list-item__text").textContent + confirmDialog(window.siyuan.languages.delete, `${window.siyuan.languages.confirmDelete} ${escapeHtml(bookmark)}?`, () => { + if (id) { fetchPost("/api/attr/setBlockAttrs", {id, attrs: {bookmark: ""}}, () => { this.update(); }); @@ -140,10 +142,14 @@ export class Bookmark extends Model { bookmarkElement.remove(); } }); - }); - } - }).element); - } + } else { + fetchPost("/api/bookmark/removeBookmark", {bookmark}, () => { + this.update(); + }); + } + }); + } + }).element); window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); }, ctrlClick(element: HTMLElement) {