This commit is contained in:
Vanessa 2023-05-10 15:57:15 +08:00
parent ca2ed12c6e
commit f8ec38e416
3 changed files with 27 additions and 15 deletions

View file

@ -73,12 +73,16 @@ export class Bookmark extends Model {
this.tree = new Tree({
element: this.element.lastElementChild as HTMLElement,
data: null,
click:(element: HTMLElement, event: MouseEvent)=> {
const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action");
if (actionElement) {
openBookmarkMenu(actionElement.parentElement, event, this);
} else {
const id = element.getAttribute("data-node-id");
click: (element: HTMLElement, event?: MouseEvent) => {
if (event) {
const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action");
if (actionElement) {
openBookmarkMenu(actionElement.parentElement, event, this);
return;
}
}
const id = element.getAttribute("data-node-id");
if (id) {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({
id,

View file

@ -9,6 +9,11 @@ import {isMobile} from "../util/functions";
import {MobileBookmarks} from "../mobile/dock/MobileBookmarks";
export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookmarkObj: Bookmark | MobileBookmarks) => {
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
window.siyuan.menus.menu.element.getAttribute("data-name") === "bookmarkMenu") {
window.siyuan.menus.menu.remove();
return;
}
window.siyuan.menus.menu.remove();
const id = element.getAttribute("data-node-id");
if (!id && !window.siyuan.config.readonly) {
@ -79,6 +84,7 @@ export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookma
}
}).element);
}
window.siyuan.menus.menu.element.setAttribute("data-name", "bookmarkMenu");
window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
window.siyuan.menus.menu.popup({x: event.clientX - 11, y: event.clientY + 11, h: 22});
};

View file

@ -28,16 +28,18 @@ export class MobileBookmarks {
this.tree = new Tree({
element: this.element.querySelector(".bookmarkList") as HTMLElement,
data: null,
click: (element: HTMLElement, event: MouseEvent) => {
click: (element: HTMLElement, event?: MouseEvent) => {
const id = element.getAttribute("data-node-id");
const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action");
if (actionElement) {
openBookmarkMenu(actionElement.parentElement, event, this);
} else {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openMobileFileById(id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]);
});
if (event) {
const actionElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item__action");
if (actionElement) {
openBookmarkMenu(actionElement.parentElement, event, this);
return;
}
}
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openMobileFileById(id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML]);
});
},
blockExtHTML: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>',
topExtHTML: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>'