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")) { if (document.activeElement && this.layout.element.contains(document.activeElement) && document.activeElement.classList.contains("b3-text-field")) {
return; return;
} }
const dialogElement = document.querySelector(".b3-dialog") as HTMLElement const dialogElement = document.querySelector(".b3-dialog") as HTMLElement;
const blockElement = document.querySelector(".block__popover") as HTMLElement const blockElement = document.querySelector(".block__popover") as HTMLElement;
const menuElement = document.querySelector("#commonMenu:not(.fn__none)") as HTMLElement const menuElement = document.querySelector("#commonMenu:not(.fn__none)") as HTMLElement;
if ((dialogElement && dialogElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上修改 emoji 时 if ((dialogElement && dialogElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上修改 emoji 时
(blockElement && blockElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上弹出悬浮层 (blockElement && blockElement.style.zIndex > this.layout.element.style.zIndex) || // 文档树上弹出悬浮层
(menuElement && menuElement.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; return false;
} }
let target = event.target let target = event.target;
while (target && !target.isEqualNode(blockElement)) { while (target && !target.isEqualNode(blockElement)) {
const type = target.getAttribute("data-type") const type = target.getAttribute("data-type");
if (type === "av-header-add") { if (type === "av-header-add") {
const addMenu = addCol(protyle, blockElement); const addMenu = addCol(protyle, blockElement);
const addRect = target.getBoundingClientRect(); const addRect = target.getBoundingClientRect();
@ -242,7 +242,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true; return true;
} else if (target.classList.contains("item") && target.parentElement.classList.contains("layout-tab-bar")) { } else if (target.classList.contains("item") && target.parentElement.classList.contains("layout-tab-bar")) {
if (target.classList.contains("item--focus")) { if (target.classList.contains("item--focus")) {
openViewMenu({protyle, blockElement, element:target}) openViewMenu({protyle, blockElement, element:target});
} else { } else {
blockElement.removeAttribute("data-render"); blockElement.removeAttribute("data-render");
avRender(blockElement, protyle, undefined, target.dataset.id); avRender(blockElement, protyle, undefined, target.dataset.id);

View file

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

View file

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

View file

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

View file

@ -1362,7 +1362,7 @@ export class WYSIWYG {
if (!nodeElement) { if (!nodeElement) {
return false; return false;
} }
const avCellHeaderElement = hasClosestByClassName(target, "av__cellheader") const avCellHeaderElement = hasClosestByClassName(target, "av__cellheader");
if (avCellHeaderElement) { if (avCellHeaderElement) {
showColMenu(protyle, nodeElement, target.parentElement); showColMenu(protyle, nodeElement, target.parentElement);
event.stopPropagation(); event.stopPropagation();
@ -1374,7 +1374,7 @@ export class WYSIWYG {
if (avTabHeaderElement.classList.contains("item--focus")) { if (avTabHeaderElement.classList.contains("item--focus")) {
openViewMenu({protyle, blockElement:nodeElement, element:target}); openViewMenu({protyle, blockElement:nodeElement, element:target});
} else { } else {
nodeElement.removeAttribute("data-render") nodeElement.removeAttribute("data-render");
avRender(nodeElement, protyle, () => { avRender(nodeElement, protyle, () => {
openViewMenu({protyle, blockElement:nodeElement, element:nodeElement.querySelector(".item.item--focus")}); openViewMenu({protyle, blockElement:nodeElement, element:nodeElement.querySelector(".item.item--focus")});
}, avTabHeaderElement.dataset.id); }, avTabHeaderElement.dataset.id);
@ -1484,12 +1484,12 @@ export class WYSIWYG {
const rowElement = hasClosestByClassName(event.target, "av__row"); const rowElement = hasClosestByClassName(event.target, "av__row");
if (rowElement && rowElement.dataset.id) { if (rowElement && rowElement.dataset.id) {
const guttersElement = rowElement.querySelector(".av__gutters"); 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; let guttersLeft = rowElement.parentElement.parentElement.getBoundingClientRect().left - guttersElement.clientWidth;
const contentLeft = protyle.contentElement.getBoundingClientRect().left const contentLeft = protyle.contentElement.getBoundingClientRect().left;
if (guttersLeft < contentLeft) { if (guttersLeft < contentLeft) {
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`); 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(); event.preventDefault();
break; break;
} else if (target.id === "searchInclude") { } else if (target.id === "searchInclude") {
const svgElement = target.firstElementChild const svgElement = target.firstElementChild;
svgElement.classList.toggle("ft__primary"); svgElement.classList.toggle("ft__primary");
if (!svgElement.classList.contains("ft__primary")) { if (!svgElement.classList.contains("ft__primary")) {
config.idPath.forEach((item, index) => { config.idPath.forEach((item, index) => {