mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
This commit is contained in:
parent
bf38219c0a
commit
a3252dbce5
1 changed files with 40 additions and 41 deletions
|
|
@ -728,6 +728,12 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
||||||
refreshTimeouts[protyle.id] = window.setTimeout(() => {
|
refreshTimeouts[protyle.id] = window.setTimeout(() => {
|
||||||
// 修改表格名 avID 传入到 id 上了 https://github.com/siyuan-note/siyuan/issues/12724
|
// 修改表格名 avID 传入到 id 上了 https://github.com/siyuan-note/siyuan/issues/12724
|
||||||
const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID;
|
const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID;
|
||||||
|
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] .custom-attr > [data-av-id="${avID}"]`) as HTMLElement;
|
||||||
|
if (attrElement) {
|
||||||
|
// 更新属性面板
|
||||||
|
attrElement.removeAttribute("data-rendering");
|
||||||
|
renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);
|
||||||
|
}
|
||||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${avID}"]`)).forEach((item: HTMLElement) => {
|
Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${avID}"]`)).forEach((item: HTMLElement) => {
|
||||||
item.removeAttribute("data-render");
|
item.removeAttribute("data-render");
|
||||||
if (operation.action === "sortAttrViewRow") {
|
if (operation.action === "sortAttrViewRow") {
|
||||||
|
|
@ -763,51 +769,44 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
||||||
}
|
}
|
||||||
const hasGhost = item.querySelector('[data-type="ghost"]');
|
const hasGhost = item.querySelector('[data-type="ghost"]');
|
||||||
avRender(item, protyle, () => {
|
avRender(item, protyle, () => {
|
||||||
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] .custom-attr > [data-av-id="${avID}"]`) as HTMLElement;
|
if (operation.action === "insertAttrViewBlock" && operation.context?.ignoreTip !== "true") {
|
||||||
if (attrElement) {
|
if (operation.context?.message) {
|
||||||
// 更新属性面板
|
showMessage(operation.context.message);
|
||||||
attrElement.removeAttribute("data-rendering");
|
} else {
|
||||||
renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);
|
const groupQuery = operation.groupID ? `[data-group-id="${operation.groupID}"]` : "";
|
||||||
} else {
|
if (item.getAttribute("data-av-type") === "gallery") {
|
||||||
if (operation.action === "insertAttrViewBlock" && operation.context?.ignoreTip !== "true") {
|
operation.srcs.forEach(srcItem => {
|
||||||
if (operation.context?.message) {
|
const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.itemID}"]`)?.querySelector(".av__gallery-fields");
|
||||||
showMessage(operation.context.message);
|
if (filesElement && filesElement.querySelector('[data-dtype="block"]')?.parentElement.getAttribute("data-empty") === "true") {
|
||||||
} else {
|
filesElement.classList.add("av__gallery-fields--edit");
|
||||||
const groupQuery = operation.groupID ? `[data-group-id="${operation.groupID}"]` : "";
|
|
||||||
if (item.getAttribute("data-av-type") === "gallery") {
|
|
||||||
operation.srcs.forEach(srcItem => {
|
|
||||||
const filesElement = item.querySelector(`.av__body${groupQuery} .av__gallery-item[data-id="${srcItem.itemID}"]`)?.querySelector(".av__gallery-fields");
|
|
||||||
if (filesElement && filesElement.querySelector('[data-dtype="block"]')?.parentElement.getAttribute("data-empty") === "true") {
|
|
||||||
filesElement.classList.add("av__gallery-fields--edit");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (operation.srcs.length === 1) {
|
|
||||||
let popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`) as HTMLElement;
|
|
||||||
if (!popCellElement) {
|
|
||||||
const popCellElements = item.querySelectorAll(`.av__body [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`);
|
|
||||||
if (popCellElements.length === 1) {
|
|
||||||
popCellElement = popCellElements[0] as HTMLElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (popCellElement && popCellElement.getAttribute("data-detached") === "true" &&
|
|
||||||
popCellElement.querySelector(".av__celltext").textContent === "" &&
|
|
||||||
popCellElement.getBoundingClientRect().height !== 0 && hasGhost) {
|
|
||||||
popTextCell(protyle, [popCellElement], "block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
operation.srcs.find((srcItem) => {
|
|
||||||
if (!item.querySelector(`.av__body [data-id="${srcItem.itemID}"]`) &&
|
|
||||||
!item.querySelector(`.av__body [data-dtype="block"] .av__celltext--ref[data-id="${srcItem.id}"]`)) {
|
|
||||||
showMessage(window.siyuan.languages.insertRowTip);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (operation.action === "addAttrViewView") {
|
if (operation.srcs.length === 1) {
|
||||||
if (item.getAttribute("data-node-id") === operation.blockID) {
|
let popCellElement = item.querySelector(`.av__body${groupQuery} [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`) as HTMLElement;
|
||||||
openMenuPanel({protyle, blockElement: item, type: "config"});
|
if (!popCellElement) {
|
||||||
|
const popCellElements = item.querySelectorAll(`.av__body [data-id="${operation.srcs[0].itemID}"] .av__cell[data-dtype="block"]`);
|
||||||
|
if (popCellElements.length === 1) {
|
||||||
|
popCellElement = popCellElements[0] as HTMLElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (popCellElement && popCellElement.getAttribute("data-detached") === "true" &&
|
||||||
|
popCellElement.querySelector(".av__celltext").textContent === "" &&
|
||||||
|
popCellElement.getBoundingClientRect().height !== 0 && hasGhost) {
|
||||||
|
popTextCell(protyle, [popCellElement], "block");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
operation.srcs.find((srcItem) => {
|
||||||
|
if (!item.querySelector(`.av__body [data-id="${srcItem.itemID}"]`) &&
|
||||||
|
!item.querySelector(`.av__body [data-dtype="block"] .av__celltext--ref[data-id="${srcItem.id}"]`)) {
|
||||||
|
showMessage(window.siyuan.languages.insertRowTip);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (operation.action === "addAttrViewView") {
|
||||||
|
if (item.getAttribute("data-node-id") === operation.blockID) {
|
||||||
|
openMenuPanel({protyle, blockElement: item, type: "config"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item.removeAttribute("data-loading");
|
item.removeAttribute("data-loading");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue