Vanessa 2025-08-08 16:24:42 +08:00
parent 9f5f5e128b
commit 5ad8b148a5
5 changed files with 15 additions and 15 deletions

View file

@ -148,7 +148,7 @@ export class Protyle {
} }
break; break;
case "refreshAttributeView": case "refreshAttributeView":
Array.from(this.protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${data.data.id}"]`)).forEach((item: HTMLElement) => { Array.from(this.protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${data.data.id}"]`)).forEach((item: HTMLElement) => {
item.removeAttribute("data-render"); item.removeAttribute("data-render");
avRender(item, this.protyle); avRender(item, this.protyle);
}); });

View file

@ -791,7 +791,7 @@ export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
nameElement.dataset.title = newData; nameElement.dataset.title = newData;
// 当前页面不能进行推送,否则光标会乱跳 // 当前页面不能进行推送,否则光标会乱跳
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => {
if (blockElement === item) { if (blockElement === item) {
return; return;
} }

View file

@ -211,7 +211,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
if (element.innerHTML) { if (element.innerHTML) {
// 防止 blockElement 找不到 // 防止 blockElement 找不到
element.querySelector(`div[data-node-id="${id}"][data-av-id="${table.avID}"]`).innerHTML = innerHTML; element.querySelector(`.av[data-node-id="${id}"][data-av-id="${table.avID}"]`).innerHTML = innerHTML;
} }
}); });
if (element.innerHTML === "") { if (element.innerHTML === "") {

View file

@ -564,7 +564,7 @@ const refreshTimeouts: {
export const refreshAV = (protyle: IProtyle, operation: IOperation) => { export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
if (operation.action === "setAttrViewName") { if (operation.action === "setAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title") as HTMLElement; const titleElement = item.querySelector(".av__title") as HTMLElement;
if (!titleElement) { if (!titleElement) {
return; return;
@ -574,7 +574,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
}); });
} }
if (operation.action === "setAttrViewColWidth") { if (operation.action === "setAttrViewColWidth") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
const cellElement = item.querySelector(`.av__cell[data-col-id="${operation.id}"]`) as HTMLElement; const cellElement = item.querySelector(`.av__cell[data-col-id="${operation.id}"]`) as HTMLElement;
if (!cellElement || cellElement.style.width === operation.data || item.getAttribute(Constants.CUSTOM_SY_AV_VIEW) !== operation.keyID) { if (!cellElement || cellElement.style.width === operation.data || item.getAttribute(Constants.CUSTOM_SY_AV_VIEW) !== operation.keyID) {
return; return;
@ -586,7 +586,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "setAttrViewCardSize") { if (operation.action === "setAttrViewCardSize") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll(".av__gallery").forEach(galleryItem => { item.querySelectorAll(".av__gallery").forEach(galleryItem => {
galleryItem.classList.remove("av__gallery--small", "av__gallery--big"); galleryItem.classList.remove("av__gallery--small", "av__gallery--big");
if (operation.data === 0) { if (operation.data === 0) {
@ -599,7 +599,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "setAttrViewCardAspectRatio") { if (operation.action === "setAttrViewCardAspectRatio") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll(".av__gallery-cover").forEach(coverItem => { item.querySelectorAll(".av__gallery-cover").forEach(coverItem => {
coverItem.className = "av__gallery-cover av__gallery-cover--" + operation.data; coverItem.className = "av__gallery-cover av__gallery-cover--" + operation.data;
}); });
@ -607,7 +607,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "hideAttrViewName") { if (operation.action === "hideAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title"); const titleElement = item.querySelector(".av__title");
if (titleElement) { if (titleElement) {
if (!operation.data) { if (!operation.data) {
@ -630,7 +630,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "setAttrViewWrapField") { if (operation.action === "setAttrViewWrapField") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll(".av__cell").forEach(fieldItem => { item.querySelectorAll(".av__cell").forEach(fieldItem => {
fieldItem.setAttribute("data-wrap", operation.data.toString()); fieldItem.setAttribute("data-wrap", operation.data.toString());
}); });
@ -638,7 +638,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "setAttrViewShowIcon") { if (operation.action === "setAttrViewShowIcon") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll('.av__cell[data-dtype="block"] .b3-menu__avemoji, .av__cell[data-dtype="relation"] .b3-menu__avemoji').forEach(cellItem => { item.querySelectorAll('.av__cell[data-dtype="block"] .b3-menu__avemoji, .av__cell[data-dtype="relation"] .b3-menu__avemoji').forEach(cellItem => {
if (operation.data) { if (operation.data) {
cellItem.classList.remove("fn__none"); cellItem.classList.remove("fn__none");
@ -650,7 +650,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "setAttrViewColWrap") { if (operation.action === "setAttrViewColWrap") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll(`.av__cell[data-col-id="${operation.id}"],.av__cell[data-field-id="${operation.id}"]`).forEach(cellItem => { item.querySelectorAll(`.av__cell[data-col-id="${operation.id}"],.av__cell[data-field-id="${operation.id}"]`).forEach(cellItem => {
cellItem.setAttribute("data-wrap", operation.data.toString()); cellItem.setAttribute("data-wrap", operation.data.toString());
}); });
@ -658,7 +658,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
return; return;
} }
if (operation.action === "foldAttrViewGroup") { if (operation.action === "foldAttrViewGroup") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
const foldElement = item.querySelector(`[data-type="av-group-fold"][data-id="${operation.id}"]`); const foldElement = item.querySelector(`[data-type="av-group-fold"][data-id="${operation.id}"]`);
if (operation.data) { if (operation.data) {
foldElement.firstElementChild.classList.remove("av__group-arrow--open"); foldElement.firstElementChild.classList.remove("av__group-arrow--open");
@ -676,7 +676,7 @@ 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;
Array.from(protyle.wysiwyg.element.querySelectorAll(`[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 === "sortAttrViewCol" || operation.action === "sortAttrViewRow") { if (operation.action === "sortAttrViewCol" || operation.action === "sortAttrViewRow") {
item.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => { item.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
@ -708,7 +708,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
} }
} }
avRender(item, protyle, () => { avRender(item, protyle, () => {
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] div[data-av-id="${avID}"]`) as HTMLElement; const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] .av[data-av-id="${avID}"]`) as HTMLElement;
if (attrElement) { if (attrElement) {
// 更新属性面板 // 更新属性面板
renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle); renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);

View file

@ -870,7 +870,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
refreshAV(protyle, operation); refreshAV(protyle, operation);
} else if (operation.action === "setAttrViewName") { } else if (operation.action === "setAttrViewName") {
// setAttrViewName 同文档不会推送,需手动刷新 // setAttrViewName 同文档不会推送,需手动刷新
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title") as HTMLElement; const titleElement = item.querySelector(".av__title") as HTMLElement;
if (!titleElement) { if (!titleElement) {
return; return;