This commit is contained in:
Vanessa 2023-12-19 11:16:38 +08:00
parent bfa4e8af7a
commit 99cf40b12d
3 changed files with 11 additions and 3 deletions

View File

@ -215,7 +215,10 @@ export class BlockPanel {
this.element = undefined; this.element = undefined;
this.targetElement = undefined; this.targetElement = undefined;
// 移除弹出上使用右键菜单 // 移除弹出上使用右键菜单
window.siyuan.menus.menu.remove(); if (window.siyuan.menus.menu.element.dataset.from !== "app") {
// https://github.com/siyuan-note/siyuan/issues/9854 右键菜单不是从浮窗中弹出的则不进行移除
window.siyuan.menus.menu.remove();
}
} }
private render() { private render() {

View File

@ -84,7 +84,7 @@ export class Menu {
} }
public addSeparator(index?: number) { public addSeparator(index?: number) {
return this.addItem({type: "separator", index}); return this.addItem({type: "separator", index});
} }
public addItem(option: IMenu) { public addItem(option: IMenu) {
@ -109,6 +109,7 @@ export class Menu {
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen"); this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex this.element.removeAttribute("style"); // zIndex
window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失 window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失
window.siyuan.menus.menu.element.removeAttribute("data-from"); // 标识是否在浮窗内打开
} }
public append(element?: HTMLElement, index?: number) { public append(element?: HTMLElement, index?: number) {

View File

@ -279,7 +279,7 @@ export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement
y: rect.top + 26, y: rect.top + 26,
h: 26 h: 26
}); });
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
anchorElement.select(); anchorElement.select();
window.siyuan.menus.menu.removeCB = () => { window.siyuan.menus.menu.removeCB = () => {
if (nodeElement.outerHTML !== oldHTML) { if (nodeElement.outerHTML !== oldHTML) {
@ -583,6 +583,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
y: rect.top + 26, y: rect.top + 26,
h: 26 h: 26
}); });
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
if (!protyle.disabled) { if (!protyle.disabled) {
window.siyuan.menus.menu.element.querySelector("input").select(); window.siyuan.menus.menu.element.querySelector("input").select();
window.siyuan.menus.menu.removeCB = () => { window.siyuan.menus.menu.removeCB = () => {
@ -1062,6 +1063,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
} }
window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY}); window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY});
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
if (!protyle.disabled) { if (!protyle.disabled) {
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea"); const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
textElements[0].focus(); textElements[0].focus();
@ -1248,6 +1250,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
y: rect.top + 26, y: rect.top + 26,
h: 26 h: 26
}); });
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea"); const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) { if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {
textElements[1].select(); textElements[1].select();
@ -1384,6 +1387,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
y: rect.top + 26, y: rect.top + 26,
h: 26 h: 26
}); });
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
window.siyuan.menus.menu.element.querySelector("input").select(); window.siyuan.menus.menu.element.querySelector("input").select();
}; };