mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-26 19:38:48 +01:00
This commit is contained in:
parent
eb92b9acf4
commit
3ec2ff243f
5 changed files with 49 additions and 25 deletions
|
|
@ -211,11 +211,13 @@ export class BlockPanel {
|
|||
});
|
||||
this.editors = [];
|
||||
}
|
||||
const level = parseInt(this.element.dataset.level);
|
||||
this.element.remove();
|
||||
this.element = undefined;
|
||||
this.targetElement = undefined;
|
||||
// 移除弹出上使用右键菜单
|
||||
if (window.siyuan.menus.menu.element.dataset.from !== "app") {
|
||||
const menuLevel = parseInt(window.siyuan.menus.menu.element.dataset.from)
|
||||
if (window.siyuan.menus.menu.element.dataset.from !== "app" && menuLevel && menuLevel >= level) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/9854 右键菜单不是从浮窗中弹出的则不进行移除
|
||||
window.siyuan.menus.menu.remove();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import {BlockPanel} from "./Panel";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||
import {
|
||||
hasClosestBlock,
|
||||
hasClosestByAttribute,
|
||||
hasClosestByClassName,
|
||||
} from "../protyle/util/hasClosest";
|
||||
import {fetchSyncPost} from "../util/fetch";
|
||||
import {hideTooltip, showTooltip} from "../dialog/tooltip";
|
||||
import {getIdFromSYProtocol} from "../util/pathName";
|
||||
|
|
@ -174,23 +178,32 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
const menuLevel = parseInt(window.siyuan.menus.menu.element.dataset.from);
|
||||
if (blockElement) {
|
||||
for (let i = 0; i < window.siyuan.blockPanels.length; i++) {
|
||||
for (let i = window.siyuan.blockPanels.length - 1; i >= 0; i--) {
|
||||
const item = window.siyuan.blockPanels[i];
|
||||
const itemLevel = parseInt(item.element.getAttribute("data-level"))
|
||||
if ((item.targetElement || typeof item.x === "number") &&
|
||||
parseInt(item.element.getAttribute("data-level")) > (maxEditLevels[item.element.getAttribute("data-oid")] || 0) &&
|
||||
itemLevel > (maxEditLevels[item.element.getAttribute("data-oid")] || 0) &&
|
||||
item.element.getAttribute("data-pin") === "false" &&
|
||||
parseInt(item.element.getAttribute("data-level")) > parseInt(blockElement.getAttribute("data-level"))) {
|
||||
item.destroy();
|
||||
i--;
|
||||
itemLevel > parseInt(blockElement.getAttribute("data-level"))) {
|
||||
if (menuLevel && menuLevel >= itemLevel) {
|
||||
// 有 gutter 菜单时不隐藏
|
||||
} else {
|
||||
item.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < window.siyuan.blockPanels.length; i++) {
|
||||
for (let i = window.siyuan.blockPanels.length - 1; i >= 0; i--) {
|
||||
const item = window.siyuan.blockPanels[i];
|
||||
const itemLevel = parseInt(item.element.getAttribute("data-level"));
|
||||
if ((item.targetElement || typeof item.x === "number") && item.element.getAttribute("data-pin") === "false") {
|
||||
item.destroy();
|
||||
i--;
|
||||
if (menuLevel && menuLevel >= itemLevel) {
|
||||
// 有 gutter 菜单时不隐藏
|
||||
} else {
|
||||
item.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
hasClosestBlock,
|
||||
hasClosestByAttribute,
|
||||
hasClosestByClassName,
|
||||
hasClosestByMatchTag
|
||||
hasClosestByMatchTag, hasTopClosestByClassName
|
||||
} from "../protyle/util/hasClosest";
|
||||
import {MenuItem} from "./Menu";
|
||||
import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection";
|
||||
|
|
@ -294,7 +294,8 @@ export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement
|
|||
y: rect.top + 26,
|
||||
h: 26
|
||||
});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
anchorElement.select();
|
||||
window.siyuan.menus.menu.removeCB = () => {
|
||||
if (nodeElement.outerHTML !== oldHTML) {
|
||||
|
|
@ -601,7 +602,8 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
y: rect.top + 26,
|
||||
h: 26
|
||||
});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.element.querySelector("input").select();
|
||||
window.siyuan.menus.menu.removeCB = () => {
|
||||
|
|
@ -1080,7 +1082,8 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
|||
}
|
||||
|
||||
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");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
if (!protyle.disabled) {
|
||||
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
||||
textElements[0].focus();
|
||||
|
|
@ -1275,7 +1278,8 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
|||
y: rect.top + 26,
|
||||
h: 26
|
||||
});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {
|
||||
inputElements[1].select();
|
||||
} else {
|
||||
|
|
@ -1415,7 +1419,8 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
|
|||
y: rect.top + 26,
|
||||
h: 26
|
||||
});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
window.siyuan.menus.menu.element.querySelector("input").select();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
hasClosestByAttribute,
|
||||
hasClosestByClassName,
|
||||
hasClosestByMatchTag,
|
||||
hasClosestByTag
|
||||
hasClosestByTag, hasTopClosestByClassName
|
||||
} from "../util/hasClosest";
|
||||
import {getIconByType} from "../../editor/getIcon";
|
||||
import {enterBack, iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
|
||||
|
|
@ -312,7 +312,8 @@ export class Gutter {
|
|||
window.siyuan.menus.menu.fullscreen();
|
||||
} else {
|
||||
window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
focusByRange(protyle.toolbar.range);
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +344,8 @@ export class Gutter {
|
|||
} else if (buttonElement.dataset.type !== "NodeAttributeViewRow") {
|
||||
this.renderMenu(protyle, buttonElement);
|
||||
window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||
const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);
|
||||
window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
|
|
@ -790,7 +792,7 @@ export class Gutter {
|
|||
label: window.siyuan.languages.addToDatabase,
|
||||
icon: "iconDatabase",
|
||||
click: () => {
|
||||
openSearchAV("", this.element, (listItemElement) => {
|
||||
openSearchAV("", selectsElement[0] as HTMLElement, (listItemElement) => {
|
||||
const sourceIds: string[] = [];
|
||||
selectsElement.forEach(item => {
|
||||
sourceIds.push(item.getAttribute("data-node-id"));
|
||||
|
|
@ -1242,7 +1244,7 @@ export class Gutter {
|
|||
label: window.siyuan.languages.addToDatabase,
|
||||
icon: "iconDatabase",
|
||||
click: () => {
|
||||
openSearchAV("", this.element, (listItemElement) => {
|
||||
openSearchAV("", nodeElement as HTMLElement, (listItemElement) => {
|
||||
const sourceIds: string[] = [nodeElement.getAttribute("data-node-id")];
|
||||
const avID = listItemElement.dataset.avId;
|
||||
transaction(protyle, [{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {Menu} from "../../../plugin/Menu";
|
||||
import {hasClosestByClassName} from "../../util/hasClosest";
|
||||
import {hasClosestByClassName, hasTopClosestByClassName} from "../../util/hasClosest";
|
||||
import {upDownHint} from "../../../util/upDownHint";
|
||||
import {fetchPost} from "../../../util/fetch";
|
||||
import {escapeHtml} from "../../../util/escape";
|
||||
import {escapeGreat, escapeHtml} from "../../../util/escape";
|
||||
import {transaction} from "../../wysiwyg/transaction";
|
||||
import {updateCellsValue} from "./cell";
|
||||
import {updateAttrViewCellAnimation} from "./action";
|
||||
|
|
@ -23,7 +23,7 @@ const genSearchList = (element: Element, keyword: string, avId: string, cb?: ()
|
|||
<div class="b3-list-item__first">
|
||||
<span class="b3-list-item__text">${escapeHtml(item.avName || window.siyuan.languages.title)}</span>
|
||||
</div>
|
||||
<div class="b3-list-item__meta b3-list-item__showall">${escapeHtml(item.hPath)}</div>
|
||||
<div class="b3-list-item__meta b3-list-item__showall">${escapeGreat(item.hPath)}</div>
|
||||
</div>
|
||||
<svg aria-label="${window.siyuan.languages.thisDatabase}" style="margin: 0 0 0 4px" class="b3-list-item__hinticon ariaLabel${item.avID === avId ? "" : " fn__none"}"><use xlink:href="#iconInfo"></use></svg>
|
||||
</div>`;
|
||||
|
|
@ -115,6 +115,8 @@ export const openSearchAV = (avId: string, target: HTMLElement, cb?: (element: H
|
|||
}
|
||||
});
|
||||
menu.element.querySelector(".b3-menu__items").setAttribute("style", "overflow: initial");
|
||||
const popoverElement = hasTopClosestByClassName(target, "block__popover", true);
|
||||
menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");
|
||||
};
|
||||
|
||||
export const updateRelation = (options: {
|
||||
|
|
@ -251,7 +253,7 @@ export const bindRelationEvent = (options: {
|
|||
fetchPost("/api/av/getAttributeViewPrimaryKeyValues", {
|
||||
id: options.menuElement.firstElementChild.getAttribute("data-av-id"),
|
||||
}, response => {
|
||||
const cells=response.data.rows.values as IAVCellValue[];
|
||||
const cells = response.data.rows.values as IAVCellValue[];
|
||||
let html = "";
|
||||
let selectHTML = "";
|
||||
hasIds.forEach(hasId => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue