This commit is contained in:
Vanessa 2023-12-01 11:50:34 +08:00
parent 5b4ad7ae17
commit d6481711af
7 changed files with 30 additions and 30 deletions

View file

@ -292,9 +292,9 @@ export class Dock {
if (document.activeElement && this.layout.element.contains(document.activeElement) && document.activeElement.classList.contains("b3-text-field")) {
return;
}
const dialogElement = document.querySelector(".b3-dialog") as HTMLElement
const blockElement = document.querySelector(".block__popover") as HTMLElement
const menuElement = document.querySelector("#commonMenu:not(.fn__none)") as HTMLElement
const dialogElement = document.querySelector(".b3-dialog") as HTMLElement;
const blockElement = document.querySelector(".block__popover") as HTMLElement;
const menuElement = document.querySelector("#commonMenu:not(.fn__none)") as HTMLElement;
if ((dialogElement && dialogElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上修改 emoji 时
(blockElement && blockElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上弹出悬浮层
(menuElement && menuElement.style.zIndex > this.layout.element.style.zIndex) // 面板上弹出菜单时

View file

@ -58,9 +58,9 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return false;
}
let target = event.target
let target = event.target;
while (target && !target.isEqualNode(blockElement)) {
const type = target.getAttribute("data-type")
const type = target.getAttribute("data-type");
if (type === "av-header-add") {
const addMenu = addCol(protyle, blockElement);
const addRect = target.getBoundingClientRect();
@ -242,7 +242,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true;
} else if (target.classList.contains("item") && target.parentElement.classList.contains("layout-tab-bar")) {
if (target.classList.contains("item--focus")) {
openViewMenu({protyle, blockElement, element:target})
openViewMenu({protyle, blockElement, element:target});
} else {
blockElement.removeAttribute("data-render");
avRender(blockElement, protyle, undefined, target.dataset.id);

View file

@ -541,7 +541,7 @@ export const openMenuPanel = (options: {
data: target.dataset.icon,
}]);
target.innerHTML = unicode ? unicode2Emoji(unicode) : '<svg><use xlink:href="#iconTable"></use></svg>';
target.dataset.icon = unicode
target.dataset.icon = unicode;
});
event.preventDefault();
event.stopPropagation();
@ -564,7 +564,7 @@ export const openMenuPanel = (options: {
break;
} else if (type === "delete-view") {
if (data.views.length === 1) {
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement))
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement));
} else {
transaction(options.protyle, [{
action: "removeAttrViewView",
@ -598,7 +598,7 @@ export const openMenuPanel = (options: {
}]);
target.innerHTML = unicode ? unicode2Emoji(unicode) : `<svg><use xlink:href="#${getColIconByType(target.dataset.colType as TAVCol)}"></use></svg>`;
updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`));
target.dataset.icon = unicode
target.dataset.icon = unicode;
});
event.preventDefault();
event.stopPropagation();

View file

@ -56,7 +56,7 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
if (typeof viewID === "string") {
newViewID = viewID;
} else if (typeof viewID === "undefined") {
newViewID = e.querySelector(".av__header .item--focus")?.getAttribute("data-id")
newViewID = e.querySelector(".av__header .item--focus")?.getAttribute("data-id");
}
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
id: e.getAttribute("data-av-id"),

View file

@ -19,11 +19,11 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
blockElement: options.blockElement,
type: "config",
cb: (avPanelElement) => {
(avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).focus()
(avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).focus();
}
});
}
})
});
menu.addItem({
icon: "iconSettings",
label: window.siyuan.languages.config,
@ -34,7 +34,7 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
type: "config"
});
}
})
});
menu.addSeparator();
menu.addItem({
icon: "iconCopy",
@ -52,13 +52,13 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
id
}]);
}
})
});
menu.addItem({
icon: "iconTrashcan",
label: window.siyuan.languages.delete,
click() {
if (options.element.parentElement.querySelectorAll("item").length === 1) {
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement))
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement));
} else {
transaction(options.protyle, [{
action: "removeAttrViewView",
@ -67,20 +67,20 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
}]);
}
}
})
const rect = options.element.getBoundingClientRect()
});
const rect = options.element.getBoundingClientRect();
menu.open({
x: rect.left,
y: rect.bottom
})
}
});
};
export const bindViewEvent = (options: {
protyle: IProtyle,
data: IAV,
menuElement: HTMLElement
}) => {
const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement;
inputElement.addEventListener("blur", () => {
if (inputElement.value !== inputElement.dataset.value) {
transaction(options.protyle, [{
@ -93,11 +93,11 @@ export const bindViewEvent = (options: {
avID: options.data.id,
id: options.data.viewID,
data: inputElement.dataset.value
}])
inputElement.dataset.value = inputElement.value
}]);
inputElement.dataset.value = inputElement.value;
}
})
}
});
};
export const getViewHTML = (data: IAVTable) => {
return `<div class="b3-menu__items">

View file

@ -1362,7 +1362,7 @@ export class WYSIWYG {
if (!nodeElement) {
return false;
}
const avCellHeaderElement = hasClosestByClassName(target, "av__cellheader")
const avCellHeaderElement = hasClosestByClassName(target, "av__cellheader");
if (avCellHeaderElement) {
showColMenu(protyle, nodeElement, target.parentElement);
event.stopPropagation();
@ -1374,7 +1374,7 @@ export class WYSIWYG {
if (avTabHeaderElement.classList.contains("item--focus")) {
openViewMenu({protyle, blockElement:nodeElement, element:target});
} else {
nodeElement.removeAttribute("data-render")
nodeElement.removeAttribute("data-render");
avRender(nodeElement, protyle, () => {
openViewMenu({protyle, blockElement:nodeElement, element:nodeElement.querySelector(".item.item--focus")});
}, avTabHeaderElement.dataset.id);
@ -1484,12 +1484,12 @@ export class WYSIWYG {
const rowElement = hasClosestByClassName(event.target, "av__row");
if (rowElement && rowElement.dataset.id) {
const guttersElement = rowElement.querySelector(".av__gutters");
guttersElement.classList.remove("av__gutters--min")
guttersElement.classList.remove("av__gutters--min");
let guttersLeft = rowElement.parentElement.parentElement.getBoundingClientRect().left - guttersElement.clientWidth;
const contentLeft = protyle.contentElement.getBoundingClientRect().left
const contentLeft = protyle.contentElement.getBoundingClientRect().left;
if (guttersLeft < contentLeft) {
guttersLeft = contentLeft;
guttersElement.classList.add("av__gutters--min")
guttersElement.classList.add("av__gutters--min");
}
guttersElement.setAttribute("style", `left:${guttersLeft}px;top:${rowElement.getBoundingClientRect().top}px`);
}

View file

@ -492,7 +492,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.preventDefault();
break;
} else if (target.id === "searchInclude") {
const svgElement = target.firstElementChild
const svgElement = target.firstElementChild;
svgElement.classList.toggle("ft__primary");
if (!svgElement.classList.contains("ft__primary")) {
config.idPath.forEach((item, index) => {