mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
8af51b8592
commit
9a9d42b078
2 changed files with 7 additions and 7 deletions
|
|
@ -1184,6 +1184,8 @@ export const openMenuPanel = (options: {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "setRelationCell") {
|
} else if (type === "setRelationCell") {
|
||||||
|
menuElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current");
|
||||||
|
target.classList.add("b3-menu__item--current");
|
||||||
setRelationCell(options.protyle, options.blockElement as HTMLElement, target, options.cellElements);
|
setRelationCell(options.protyle, options.blockElement as HTMLElement, target, options.cellElements);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, isDetached?: boolean, text?: string) => {
|
const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, isDetached?: boolean, text?: string, className?: string) => {
|
||||||
if (type === "selected") {
|
if (type === "selected") {
|
||||||
return `<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
|
return `<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
|
||||||
<span class="b3-menu__label fn__ellipsis ${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
|
<span class="b3-menu__label fn__ellipsis ${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
|
||||||
|
|
@ -224,7 +224,7 @@ const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string,
|
||||||
</button>`;
|
</button>`;
|
||||||
}
|
}
|
||||||
if (type == "unselect") {
|
if (type == "unselect") {
|
||||||
return `<button data-id="${id}" class="b3-menu__item ariaLabel" data-position="west" data-type="setRelationCell">
|
return `<button data-id="${id}" class="${className || "b3-menu__item ariaLabel"}" data-position="west" data-type="setRelationCell">
|
||||||
<span class="b3-menu__label fn__ellipsis${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
|
<span class="b3-menu__label fn__ellipsis${isDetached ? "" : " popover__block"}" ${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'} data-id="${id}">${text}</span>
|
||||||
<svg class="b3-menu__action"><use xlink:href="#iconAdd"></use></svg>
|
<svg class="b3-menu__action"><use xlink:href="#iconAdd"></use></svg>
|
||||||
</button>`;
|
</button>`;
|
||||||
|
|
@ -392,7 +392,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
|
||||||
newValue.blockIDs.splice(removeIndex, 1);
|
newValue.blockIDs.splice(removeIndex, 1);
|
||||||
newValue.contents.splice(removeIndex, 1);
|
newValue.contents.splice(removeIndex, 1);
|
||||||
separatorElement.after(target);
|
separatorElement.after(target);
|
||||||
target.outerHTML = genSelectItemHTML("unselect", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent));
|
target.outerHTML = genSelectItemHTML("unselect", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent), target.className);
|
||||||
} else if (targetId) {
|
} else if (targetId) {
|
||||||
newValue.blockIDs.push(targetId);
|
newValue.blockIDs.push(targetId);
|
||||||
newValue.contents.push({
|
newValue.contents.push({
|
||||||
|
|
@ -404,7 +404,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar
|
||||||
isDetached: !target.firstElementChild.getAttribute("style")
|
isDetached: !target.firstElementChild.getAttribute("style")
|
||||||
});
|
});
|
||||||
separatorElement.before(target);
|
separatorElement.before(target);
|
||||||
target.outerHTML = `<button data-id="${targetId}" data-position="west" data-type="setRelationCell" class="b3-menu__item ariaLabel"
|
target.outerHTML = `<button data-id="${targetId}" data-position="west" data-type="setRelationCell" class="${target.className}"
|
||||||
draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent))}</button>`;
|
draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent))}</button>`;
|
||||||
if (!separatorElement.nextElementSibling) {
|
if (!separatorElement.nextElementSibling) {
|
||||||
separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML("empty"));
|
separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML("empty"));
|
||||||
|
|
@ -438,10 +438,8 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector
|
||||||
isDetached: true
|
isDetached: true
|
||||||
});
|
});
|
||||||
separatorElement.insertAdjacentHTML("beforebegin", `<button data-id="${rowId}" data-position="west" data-type="setRelationCell"
|
separatorElement.insertAdjacentHTML("beforebegin", `<button data-id="${rowId}" data-position="west" data-type="setRelationCell"
|
||||||
class="b3-menu__item ariaLabel" draggable="true">${genSelectItemHTML("selected", rowId, true, Lute.EscapeHTMLStr(content))}</button>`);
|
class="${target.className} ariaLabel" draggable="true">${genSelectItemHTML("selected", rowId, true, Lute.EscapeHTMLStr(content))}</button>`);
|
||||||
}
|
}
|
||||||
menuElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current");
|
|
||||||
menuElement.querySelector(".b3-menu__items .b3-menu__item:not(.fn__none)").classList.add("b3-menu__item--current");
|
|
||||||
}
|
}
|
||||||
updateCellsValue(protyle, nodeElement, newValue, cellElements);
|
updateCellsValue(protyle, nodeElement, newValue, cellElements);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue